Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Thanked 0 Times in 0 Posts

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

    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");
    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.

  • #2
    New Coder
    Join Date
    Dec 2008
    Thanked 1 Time in 1 Post
    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!


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts