JS page content change?
- Started
- Last post
- 20 Responses
- J
Hello you.
I'm looking for a way to load an external chunk of html, into a defined region in a page, when clicking a link in the page.
IE. You click a navigational option, the page contents changes (loaded from an EXTERNAL include file) but the whole page doesnt reload.
Anyone have any code for this?
Help!
Thanks in advance.
xxx
- J0
Oh and, sorry - i'm not stupid or anything.... iframes are already ruled out. Hard to explain, nothing to do with backwards browser compatability, just the way the site needs to work.
Confused? Well, esentially, when the new content loads into the page, the length of the page needs to change to accommodate. Does that make sense?
- stewart0
i thought that you could change the dimensions of the i-frame dynamicly...
- JazX0
- mitsu0
why don't you just load the content when the page loads in a hidden div. then on the desired event, display it.
- stewart0
yeah mitsu, like how it is done here: http://www.derijn.nl
- J0
Change the dimensions of iframe dynamically... hmmm.... possibly...
I can't really load the content into the page, but hidden... because that would mean loading the whole site into the page!
- mitsu0
"because that would mean loading the whole site into the page!"
i don't follow you. is the content not the same each time? can you elaborate?
- J0
ERm... i don't really know how else to say it...
the content, which wants to be loaded into the region, is the sub page content for the site. I want to have ALL the pages of the site as chunks of code that will load into the defined region when you click and navigate to them. SO, if i load all the content into the page from the word go, well, there could be like 100's of pages.... that's a whole lot of code to load into the page!
Another way to look at the problem is this:
I want to use iframes, but i want to use the main browser scrollbar (the one over there on the far right of your screen! ----------->)... but if i use an iframe (with scrollbars turned off) I would need its hright to automaticall change to the correct height for the new content, thus showing it all / causing the page itself to scroll the correct amount to see it all.
!!!
- mitsu0
ok, so let me ask you this... the content that's being loaded... is full pages that are being loaded or just sections of content from a page you want to load?
i'm sure whatever you want can be done, i just need to understand the source content.
- J0
Ok, it's a little more complicated than this... but essentially...
I want to be able to change pages, without reloading the whole page. You click a button in the navigation, new content loads (which makes up most of the page) but the navigation remains constantly on screen.
The reason for this is, I want the navigation (and some other elements on screen) to be done in flash, and i dont want them to 'blink' on and off, and also restart, because the whole page has been reloaded.
Hmmm?
- J0
...I could solve all this by just using an iframe, if iframes automatically stretched to fit the content within them.
- mitsu0
ok, you have two options. one is the obvious choice: frames
the other, is a technology called remote scripting, which is available to you since you seem to use asp. it will load content on a page, pull data from a database all without refreshing the main page itself. have you ever used remote scripting?
- J0
Ok mitsu, thanks for trying to help but...
Frames are NOT an option... just as iframes arent... for the same reasons, yeah? How else can I explain it for you to understand!?
As for remote scripting.... I haven't a clue. But I don't really want to pull data out of a database!! And i don't know wbut... i don't see how that would help anyway... just add complication!!
- mitsu0
the point was you can EVEN pull data from a database without a page refresh. you can also load content from the server remotely without a page refresh.
good luck.
- J0
BUMP!
- J0
*cough* ?
- iodine740
Essentially you could do something sort of like what you want to do,but using Javascript and changing the innerHTML property of a Div. Not sure if height of the Div would adjust though.
Would also sort of be messy.
Why not just make the whole site Flash and load content remotely?
- oliveira0
so many posts, so little help.
one word: DOM. dom does exactly what you're trying to acomplish.have you checked the genlib by microbians?
go google for DOM. its your answer, if you don't want to use iframes and div tags.
- mitsu0
"so many posts, so little help.
one word: DOM. dom does exactly what you're trying to acomplish."thanks for adding your worthless contribution to the list.
'dom' is what i recommended earlier when i mentioned loading the info first and then putting it in a div tag.
however, since the amount of content he would have to preload to get this to work would be the same as loading his entire site, that is not an option.
there are two ways, one is remote scripting or the other with flash. there's actually 3, but i won't mention the third for fear of getting my head bit off again.
- iodine740
If the items in your nav called javascript functions that dynamically created links to Javascript files (the one part that I'm not totally sure would work) .. and if each of those javascript files had a string variable that contained the entire set of Markup that you wanted to to be seen (ugly, but really the only way of doing it)... you could set that string to be the inner HTML of the div. And so the inner HTML gets switched out every time. I don't think you'd run into scope issues. The only problem is.. by the time they've linked to all the pages in the site... that's kinda a heavy memory load. I'm not sure if there's a way you could "dump" that dynamically linked JS file so it isn't taking up memory in the DOM. Abit clugee...but it's a start.