...

View Full Version : Using innerHTML to simulate frames. Can't include JS code in a function?



RedBullBlood
01-29-2009, 10:29 PM
Hey guys,
Sorry if the title's not up to scratch, tried to be as descriptive as I could (read the posting rules).

I'm designing a website for a mock promotions firm, and currently I have a header, menu-bar (horizontal, sits under the header), a big 'content' main area, and a footer, all arranged in CSS.

The problem I'm having, is that I've got an embedded music player in the footer - and now obviously whenever I click on a link in the menu bar to take me to another page, the music re-starts, and looks very unproffessional :/

The header, menu, footer and music parts are the same for every page, so I thought I could just use


document.getElementById("content").innerHTML = "[page code here";

as a JS function mapped to "onclick" of the links in the menu bar.

It works for little quick practices, where I put text in the [page code here] for each different page - but here's the crux of the problem:

One of the pages has an embedded flash file, a photo-gallery viewer. Here is the code for the 'content' part of this gallery page:



<div id="flashcontent">
You don't seem to have flash installed. <a href="http://www.macromedia.com/go/getflashplayer/">Get It.</a></div>
<script type="text/javascript">

var fo = new SWFObject("viewer.swf", "viewer", "100%", "100%", "8", "#181818");
fo.write("content");
</script>


</div>


I uploaded this onto the webserver and gave it a go - the best I got was a dark box showing up (same colour as the photo gallery background) - not too sure what this meant happened, but needless to say, I'm stuck :(

Is it because I can't just lump all of that code into a getElementById call ?

Any and all help would be much appreciated.
Cheers

TheTot
01-30-2009, 02:41 AM
Providing us with a link to the page in question may help us.

I'm not the best at this stuff, but I use innerHTML commands a lot. You should be able to fit anything and everything you want into one of them.

The code you posted as the "content", is that exactly what you put inside the innerHTML change? Because if it is, all those double quotes ( " ) are going to cause a problem. You need to change all those to single quotes ( ' ) to prevent the javascript from thinking all you want inside the innerHTML is "<div id=".

Other than that, I can't help you more. Good luck!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum