Click to See Complete Forum and Search --> : iframe and link src problem...


hopefulcd
March 10th, 2009, 01:48 PM
Hi all, I'm having a problem with cross-browser compatibility and javascript. There are two main problems that I can't seem to get past.

1. Basically, I have a page that dynamically loads a new iframe when the user doubleclicks on an option from a select box. This is done by changing the src attribute of the iframe. This works fine on FF and Opera, but IE7 and Safari both don't work. I'll paste the code that I'm using below.

2. The second issue is similar to the first, but instead of an iframe it's a link (<a href=""...). The link's src (href) is supposed to change when the user (single) clicks on an option from the select list. Again, the code works fine on FF and Opera, but IE7 and Safari both don't work.

Any help or solutions to these problems would be greatly appreciated. Thanks.

Here's the code:

<html>
<head>
<script type="text/javascript">

function reload(selected)
{
var url = "http://woodmarchurch.org/a/" + selected;
parent.audplay.location = url;
}

function linkchange(text)
{
var url = "http://woodmarchurch.org/audio/";
var aud = text;
document.getElementById('auddown').href = (url + aud);
}


</script>
</head>
<body>

<select size="15" name="audlist" id="audlist" style="width:100%; min-width:320px; overflow:auto">
<option ondblclick="reload('aud35')" onclick="linkchange('some1.mp3')" value="aud35">Audio 1
<option ondblclick="reload('aud1')" onclick="linkchange('some2.mp3')" value="aud1">Audio 2
<option ondblclick="reload('aud54')" onclick="linkchange('some3.mp3')" value="aud54">Audio 3
<option ondblclick="reload('aud90')" onclick="linkchange('some4.mp3')" value="aud90">Audio 4
</select>

<a name="auddown" style="color:#990000" id="auddown" href=""><u>Download</u></a>

<iframe id="audplay" name="audplay" style="height:260px; width:340px; border:3px #CC0000 groove" src="http://somesite.org/a/aud87/index.html"></iframe>

</body>
</html>

PeejAvery
March 10th, 2009, 02:40 PM
Please remember to use code tags (http://www.codeguru.com/forum/misc.php?do=bbcode) when posting code. Thanks.

I believe you are making things quite harder than they need to be.

<html>
<head>
<script type="text/javascript">
function linkchange(text) {
var url = "http://somesite.org/audio/" + text;
document.getElementById('auddown').setAttribute('href', url);
}
function reload(selected) {
var url = "http://woodmarchurch.org/a/" + selected;
document.getElementById('audplay').src = url;
}
</script>
</head>
<body>

<select size="15" name="audlist" id="audlist" style="width:100%; min-width:320px; overflow:auto">
<option ondblclick="reload('aud35')" onclick="linkchange('some1.mp3')">Audio 1</option>
<option ondblclick="reload('aud1')" onclick="linkchange('some2.mp3')">Audio 2</option>
<option ondblclick="reload('aud54')" onclick="linkchange('some3.mp3')">Audio 3</option>
<option ondblclick="reload('aud90')" onclick="linkchange('some4.mp3')">Audio 4</option>
</select>

<a name="auddown" style="color:#990000" id="auddown" href=""><u>Download</u></a>

<iframe id="audplay" name="audplay" style="height:260px; width:340px; border:3px #CC0000 groove" src="http://somesite.org/a/aud87/index.html"></iframe>

</body>
</html>

hopefulcd
March 10th, 2009, 02:55 PM
I realized I had pasted some of my old trial functions instead of the current ones that I'm having trouble with. I fixed the code on my post above with the current functions. However, these are the ones that don't have cross browser compatibility. I also tried the functions that you have above but they didn't work. Any more help or suggestions would be appreciated.

PeejAvery
March 10th, 2009, 04:12 PM
I made two simple and rather stupid mistakes in my code. Check it again to see the edited version.

hopefulcd
March 10th, 2009, 06:38 PM
I tried the code that you gave on the 4 browsers. Again, the output is the same. FF and Opera both work fine, but IE7 and Safari both don't work. If there are any other coding suggestions or help it would be very much appreciated. Thanks for your help so far...

PeejAvery
March 10th, 2009, 07:08 PM
Strange. It works in IE7, Firefox, and Safari for me. Of course, I can't test the exact linkchange() function because http://somesite.org/audio/ isn't valid. But, it would load Google as the URL.

hopefulcd
March 10th, 2009, 08:19 PM
This is weird. I tried the code on my laptop and my school's computers for both the IE7 and Safari, but it didn't work. Now I'm on a different laptop and it works fine for IE7. Is there any reason why it works on some and not on others?

PeejAvery
March 11th, 2009, 07:26 AM
Do you have security software installed? Higher security on your laptop? Did you click the yellow information bar and tell your script that it was okay to run?

hopefulcd
March 11th, 2009, 01:19 PM
I lowered the security settings on IE7 a lot, but the result was the same. I'm not running any other secondary security programs besides the basic windows defender for Vista. The computers at my school are running windows XP. For some reason, the script doesn't run on either. The other day I tried a different laptop that was running Vista and it was working fine for IE7. This leads me to think that it probably is something in the browser's settings. I also had to double check to make sure that that 'Active Scripting' was enabled, but still no luck. I'm not too sure what could be causing it not to work from this point. If you know or could think of any reason or way to fix this I'd very much appreciate it. Thanks for your help.