...

View Full Version : Get Iframe Location



Metatrox
05-03-2007, 09:38 PM
Ok what I'm trying to do is have a snipet of code check the location of an iframe.

If the Iframe is at audioplayer.html I want it to do nothing.
Otherwise I want it to change to audioplayer.html


if(parent.audioframe.location.href == "http://www.newlifegallup.org/video/audioplayer.html","http://newlifegallup.org/video/audioplayer.html") { null }
else { parent.audioframe.location.href = "audioplayer.html"; }

I'm do realize "null" also probably isn't the right thing.


You can see a link of what I'm trying to do here.
http://newlifegallup.org/video/template.html

I want it so that when you open the audio or video player you can click close to completely close it, I have this setup by hiding the layer and changing the iframe to a blank page. I have it set up so if the audio player is open and i click the video player it will close the audio and change the audio iframe to blank. But when you go back to click the audio button i need it to check the iframe's location. Because I don't want it to just change the iframe location every time.

I hope this is understandable

Mr J
05-03-2007, 11:53 PM
Give this a try


if(parent.audioframe.location.href.indexOf("audioplayer.html") == -1){
parent.audioframe.location.href = "audioplayer.html"
}

Metatrox
05-04-2007, 12:13 AM
Hmmm... now the windows/layers are not even popping up.

Here is the exactly what I have



<script type="text/javascript" language="JavaScript"><!--
function FrameCheckA() {
if(parent.audioframe.location.href.indexOf("audioplayer.html") == -1{
parent.audioframe.location.href = "audioplayer.html"
}
//--></script>

I know its real ugly but the other stuff is to show the layer that has the iframe, and a couple other things.


<table width=100px height=19px cellspacing=0 border=0 cellpadding=0><tr><td align=center bgcolor="" OnClick="parent.videoframe.location.href = 'blank.html'; FrameCheckA(); ShowContent('audioplayer'); HideContent('videoplayer'); return true;" OnMouseOver="changeto(event,'a6bf6d')" OnMouseOut="changeback(event,'')" style="cursor: pointer;">
<font face=arial size=-2 color=ffffff>AUDIO PLAYER</font>
</td></tr></table>

glenngv
05-04-2007, 01:30 AM
You missed the ) and }

function FrameCheckA() {
if(parent.audioframe.location.href.indexOf("audioplayer.html") == -1) {
parent.audioframe.location.href = "audioplayer.html"
}
}

Metatrox
05-04-2007, 05:39 AM
Awesome it works!

Much appreciated guys!

That thing was driving me crazy all day.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum