OnClick & IFrames

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bryanw
    New Member
    • Aug 2007
    • 1

    OnClick & IFrames

    Hello there, I have a fairly simple problem but since my knowledge of JavaScript is limited, I'm not quite sure how to go about it.

    Basically, I am developing a website for selling my products, and I have a menu bar with all the links to these specific products. Already I have the links going into an iframe, where you see the .html file containing the picture and the product's description. What I'd like to do is actually take that descriptive text and place it outside the iframe, in a layer preferably or perhaps even another iframe, but as such ... what I'm aiming for is when you click on the link, two things happen: the iframe gives you the picture, and another layer/iframe gives you the text. Pretty simple? Will I need to make two separate .html files for each product, one for the image and one for the description?

    Thanks for your help.

    -Bryan
  • markrawlingson
    Recognized Expert Contributor
    • Aug 2007
    • 346

    #2
    [CODE=javascript]
    function SetContent(obj, sText) {
    var oObj = document.getEle mentById(obj);
    oObj.innerHTML = sText;
    }
    [/CODE]

    call it like this..

    Code:
    <a href="javascript:SetContent('yourtargetlayersid','This is a wonderful description of a superb product which you should most certainly purchase!');">Your link</a>
    You'll, of course, have to have a div/span layer on the page.

    Code:
    <div id="yourtargetlayersid"></div>
    You can use the function numerous times over, and in what ever context you wish - onmouseover, onclick, onblur, whatever...

    Comment

    Working...