Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #35182 > unrolled thread

Reach js sourcefiles within other divs

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2018-06-06 16:45 -0700
Last post2018-06-07 03:55 -0700
Articles 6 — 1 participant

Back to article view | Back to comp.lang.javascript


Contents

  Reach js sourcefiles within other divs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-06 16:45 -0700
    Re: Reach js sourcefiles within other divs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-06 16:55 -0700
      Re: Reach js sourcefiles within other divs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-06 17:11 -0700
        Re: Reach js sourcefiles within other divs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-06 17:45 -0700
          Re: Reach js sourcefiles within other divs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-07 03:45 -0700
            Re: Reach js sourcefiles within other divs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-07 03:55 -0700

#35182 — Reach js sourcefiles within other divs

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-06-06 16:45 -0700
SubjectReach js sourcefiles within other divs
Message-ID<30c8c35e-e10b-4746-8a0a-349db71396ac@googlegroups.com>
I dynamically load HTML pages into divs each HTML file invoke some js sources, i now see that the canvas that was created by HTML and JS sources in a div called main is not reachable from a later loaded div and its source js files.

I was hoping having some files and functions reachable by any project i do, and not need to incorporate them in all projects by copy.

Uncaught ReferenceError: mainctx is not defined
    at tracks_canvas.js:1

So can i somehow refer to that the js files is loaded into another div, by just use its name?

[toc] | [next] | [standalone]


#35183

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-06-06 16:55 -0700
Message-ID<d20d84e7-f46c-4c80-b505-3324eb56b01c@googlegroups.com>
In reply to#35182
Den torsdag 7 juni 2018 kl. 01:45:14 UTC+2 skrev Jonas Thörnvall:
> I dynamically load HTML pages into divs each HTML file invoke some js sources, i now see that the canvas that was created by HTML and JS sources in a div called main is not reachable from a later loaded div and its source js files.
> 
> I was hoping having some files and functions reachable by any project i do, and not need to incorporate them in all projects by copy.
> 
> Uncaught ReferenceError: mainctx is not defined
>     at tracks_canvas.js:1
> 
> So can i somehow refer to that the js files is loaded into another div, by just use its name?

Well i will move the canvas.html **"canvas delaration** into the project.html so the canvas is defined in that HTML file. But of course it must be possible to have the canvas.html and its js source files loaded but still reachable from the project.html and its source files. If you just know the way to refer to it.

[toc] | [prev] | [next] | [standalone]


#35184

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-06-06 17:11 -0700
Message-ID<21d3c988-43cd-4605-81a5-298475ad7137@googlegroups.com>
In reply to#35183
Den torsdag 7 juni 2018 kl. 01:55:10 UTC+2 skrev Jonas Thörnvall:
> Den torsdag 7 juni 2018 kl. 01:45:14 UTC+2 skrev Jonas Thörnvall:
> > I dynamically load HTML pages into divs each HTML file invoke some js sources, i now see that the canvas that was created by HTML and JS sources in a div called main is not reachable from a later loaded div and its source js files.
> > 
> > I was hoping having some files and functions reachable by any project i do, and not need to incorporate them in all projects by copy.
> > 
> > Uncaught ReferenceError: mainctx is not defined
> >     at tracks_canvas.js:1
> > 
> > So can i somehow refer to that the js files is loaded into another div, by just use its name?
> 
> Well i will move the canvas.html **"canvas delaration** into the project.html so the canvas is defined in that HTML file. But of course it must be possible to have the canvas.html and its js source files loaded but still reachable from the project.html and its source files. If you just know the way to refer to it.

I had the crazy idea that it would be cleaner using a layout.html with just the divs, load in other html docs dynamically in each div. Have a command.html in one div, canvas.html in another, UI.html in another and so on but the source files loaded with each html is local. That was not what i had in mind. I wanted to use canvas and menues and such for many projects html. Probably there is a way to use the div names to reach the js files loaded by the different HTML files.

[toc] | [prev] | [next] | [standalone]


#35185

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-06-06 17:45 -0700
Message-ID<46f51360-9812-428a-9e65-3738c97f682e@googlegroups.com>
In reply to#35184
Den torsdag 7 juni 2018 kl. 02:11:12 UTC+2 skrev Jonas Thörnvall:
> Den torsdag 7 juni 2018 kl. 01:55:10 UTC+2 skrev Jonas Thörnvall:
> > Den torsdag 7 juni 2018 kl. 01:45:14 UTC+2 skrev Jonas Thörnvall:
> > > I dynamically load HTML pages into divs each HTML file invoke some js sources, i now see that the canvas that was created by HTML and JS sources in a div called main is not reachable from a later loaded div and its source js files.
> > > 
> > > I was hoping having some files and functions reachable by any project i do, and not need to incorporate them in all projects by copy.
> > > 
> > > Uncaught ReferenceError: mainctx is not defined
> > >     at tracks_canvas.js:1
> > > 
> > > So can i somehow refer to that the js files is loaded into another div, by just use its name?
> > 
> > Well i will move the canvas.html **"canvas delaration** into the project.html so the canvas is defined in that HTML file. But of course it must be possible to have the canvas.html and its js source files loaded but still reachable from the project.html and its source files. If you just know the way to refer to it.
> 
> I had the crazy idea that it would be cleaner using a layout.html with just the divs, load in other html docs dynamically in each div. Have a command.html in one div, canvas.html in another, UI.html in another and so on but the source files loaded with each html is local. That was not what i had in mind. I wanted to use canvas and menues and such for many projects html. Probably there is a way to use the div names to reach the js files loaded by the different HTML files.

Personally i think it is kind of strange that not all things loaded in divs available?

I mean what is the purpose to not have them? The html files loaded dynamically in each are just containers, right? So would also script functions written directly in each also be local to the div?

I try to split up the mass of the interface file, but javascript seem to prefer a blob or that one learn yet another concept. What would the purpose be of have each div code "functions" separated from functions in other divs?

[toc] | [prev] | [next] | [standalone]


#35186

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-06-07 03:45 -0700
Message-ID<fe552504-389e-4a92-a81a-76bf9156186a@googlegroups.com>
In reply to#35185
Den torsdag 7 juni 2018 kl. 02:45:39 UTC+2 skrev Jonas Thörnvall:
> Den torsdag 7 juni 2018 kl. 02:11:12 UTC+2 skrev Jonas Thörnvall:
> > Den torsdag 7 juni 2018 kl. 01:55:10 UTC+2 skrev Jonas Thörnvall:
> > > Den torsdag 7 juni 2018 kl. 01:45:14 UTC+2 skrev Jonas Thörnvall:
> > > > I dynamically load HTML pages into divs each HTML file invoke some js sources, i now see that the canvas that was created by HTML and JS sources in a div called main is not reachable from a later loaded div and its source js files.
> > > > 
> > > > I was hoping having some files and functions reachable by any project i do, and not need to incorporate them in all projects by copy.
> > > > 
> > > > Uncaught ReferenceError: mainctx is not defined
> > > >     at tracks_canvas.js:1
> > > > 
> > > > So can i somehow refer to that the js files is loaded into another div, by just use its name?
> > > 
> > > Well i will move the canvas.html **"canvas delaration** into the project.html so the canvas is defined in that HTML file. But of course it must be possible to have the canvas.html and its js source files loaded but still reachable from the project.html and its source files. If you just know the way to refer to it.
> > 
> > I had the crazy idea that it would be cleaner using a layout.html with just the divs, load in other html docs dynamically in each div. Have a command.html in one div, canvas.html in another, UI.html in another and so on but the source files loaded with each html is local. That was not what i had in mind. I wanted to use canvas and menues and such for many projects html. Probably there is a way to use the div names to reach the js files loaded by the different HTML files.
> 
> Personally i think it is kind of strange that not all things loaded in divs available?
> 
> I mean what is the purpose to not have them? The html files loaded dynamically in each are just containers, right? So would also script functions written directly in each also be local to the div?
> 
> I try to split up the mass of the interface file, but javascript seem to prefer a blob or that one learn yet another concept. What would the purpose be of have each div code "functions" separated from functions in other divs?

What is the reason for the JS sources to just have a local scope within the HTML file, why are they not local to the viewport?

A div is just a layout element, it is basicly a replacement for the frame layout?

Using frames you did something like this, to access elements in other frames. But that was form elements as i remember. I have no idea how a canvas would be reached or if it even can be reached.

window.frames["framename"].document.getElementById ( "yourelementid" );

If i would dream a bit i would say

window.div["divname"].document.getElementById ( "yourelementid" );

Would be the way to do it, but there is no consitency within javascript it turned into a mismash.

[toc] | [prev] | [next] | [standalone]


#35187

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-06-07 03:55 -0700
Message-ID<053342f5-0e04-4b0c-a9bb-02d1b961270d@googlegroups.com>
In reply to#35186
Den torsdag 7 juni 2018 kl. 12:46:01 UTC+2 skrev Jonas Thörnvall:
> Den torsdag 7 juni 2018 kl. 02:45:39 UTC+2 skrev Jonas Thörnvall:
> > Den torsdag 7 juni 2018 kl. 02:11:12 UTC+2 skrev Jonas Thörnvall:
> > > Den torsdag 7 juni 2018 kl. 01:55:10 UTC+2 skrev Jonas Thörnvall:
> > > > Den torsdag 7 juni 2018 kl. 01:45:14 UTC+2 skrev Jonas Thörnvall:
> > > > > I dynamically load HTML pages into divs each HTML file invoke some js sources, i now see that the canvas that was created by HTML and JS sources in a div called main is not reachable from a later loaded div and its source js files.
> > > > > 
> > > > > I was hoping having some files and functions reachable by any project i do, and not need to incorporate them in all projects by copy.
> > > > > 
> > > > > Uncaught ReferenceError: mainctx is not defined
> > > > >     at tracks_canvas.js:1
> > > > > 
> > > > > So can i somehow refer to that the js files is loaded into another div, by just use its name?
> > > > 
> > > > Well i will move the canvas.html **"canvas delaration** into the project.html so the canvas is defined in that HTML file. But of course it must be possible to have the canvas.html and its js source files loaded but still reachable from the project.html and its source files. If you just know the way to refer to it.
> > > 
> > > I had the crazy idea that it would be cleaner using a layout.html with just the divs, load in other html docs dynamically in each div. Have a command.html in one div, canvas.html in another, UI.html in another and so on but the source files loaded with each html is local. That was not what i had in mind. I wanted to use canvas and menues and such for many projects html. Probably there is a way to use the div names to reach the js files loaded by the different HTML files.
> > 
> > Personally i think it is kind of strange that not all things loaded in divs available?
> > 
> > I mean what is the purpose to not have them? The html files loaded dynamically in each are just containers, right? So would also script functions written directly in each also be local to the div?
> > 
> > I try to split up the mass of the interface file, but javascript seem to prefer a blob or that one learn yet another concept. What would the purpose be of have each div code "functions" separated from functions in other divs?
> 
> What is the reason for the JS sources to just have a local scope within the HTML file, why are they not local to the viewport?
> 
> A div is just a layout element, it is basicly a replacement for the frame layout?
> 
> Using frames you did something like this, to access elements in other frames. But that was form elements as i remember. I have no idea how a canvas would be reached or if it even can be reached.
> 
> window.frames["framename"].document.getElementById ( "yourelementid" );
> 
> If i would dream a bit i would say
> 
> window.div["divname"].document.getElementById ( "yourelementid" );
> 
> Would be the way to do it, but there is no consitency within javascript it turned into a mismash.

Well in the end i guess i just move the code of the html pages into the div parts of layout.html and also put the references to the source files witin the same.

I thought i would be smart and go for modularity, ***but it seem to create unneccessary complexity and syntax?***

Could you not have something like import in the main HTML file "pointing at the other HTML files" , that make the js sourcefiles references within those reachable global within project?

I mean the hazzle writing deep references like

window.frames["framename"].document.getElementById ( "yourelementid" ); 

Seem unnecessary isn't it?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web