Link to home
Start Free TrialLog in
Avatar of mark951
mark951

asked on

Javascript Layer Show

I am trying to User a Imagemap to click and show a layer from an external htm file.  here is my code so far.

document.frames["layer1"].location="newlocation.html"
//loads htm file into the layer

//the Iframe
<IFRAME SRC="mission.htm" width=100% height=100% name="layer1" id="layer1"></IFRAME>

will this even work?  thanks
Avatar of Batalf
Batalf
Flag of United States of America image

Yes that should work.

You could also do by id

<IFRAME SRC="mission.htm" width=100% height=100% name="layer1" id="layer1"></IFRAME>

<script type="text/javascript">
document.getElementById('layer1').location.href="newlocation.html";
</script>

Avatar of mark951
mark951

ASKER

How do I get it to show up within a table on my current page when there is a mouse over event?
Example with image and image map:


<MAP NAME="map1">
<AREA
   HREF="#" onclick="document.getElementById('layer1').location.href='newlocation.html';"
   SHAPE=RECT COORDS="6,116,97,184">
</AREA>
</MAP>

<IMG SRC="testmap.gif"
   ALT="" BORDER=0 WIDTH=300 HEIGHT=300
   USEMAP="#map1">

<IFRAME SRC="mission.htm" width=100% height=100% name="layer1" id="layer1"></IFRAME>


What do you mean by mouse over a event?

An example of a mouse over event could be to replace onclick with onmouseover in my example above.


And to let appear within your table, just put the

<IFRAME SRC="mission.htm" width=100% height=100% name="layer1" id="layer1"></IFRAME>

in one of your table cells.
Avatar of mark951

ASKER

This is what I did:
<script type="text/javascript">
document.frames["layer1"].location="mission.htm"
</script>

//My image map
 <area shape="rect" coords="83, 128, 202, 156" href="#" onclick="document.getElementById('layer1').location.href='mission.htm';">


//put the Iframe in the Cell where I want the mission page to be displayed on my main.asp page
<IFRAME SRC="mission.htm" width=100% height=100% name="layer1" id="layer1"></IFRAME>

I must have did something wrong b/c I get this error:
document.getElementById(...).location' is null or not an object
ASKER CERTIFIED SOLUTION
Avatar of Batalf
Batalf
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial