Forum Moderators: open

Message Too Old, No Replies

IE won't call function with a link

<a href="javascript:funciton();"> not working in IE

         

kevinkp7

5:18 pm on Feb 26, 2009 (gmt 0)

10+ Year Member



The following code works in everything but IE. I get a "Object Expected" error in IE. Here's my code:

---------------------------------------------------------------
<body>

<script type="application/javascript">
var a=0;
function load_once(elementid){
a=a+1;
if(a == 1){
document.getElementById(elementid).innerHTML = '<iframe src="http://example.com" style="border:1px solid; padding:2px; width:800px; height:600px"></iframe>'
}
if (document.getElementById(elementid).style.display == 'none'){
document.getElementById(elementid).style.display = '';
} else {
document.getElementById(elementid).style.display = 'none';
}
}
</script>

<a href="#" onclick="javascript:load_once('kevink');">Click Me</a><br /><br />

<div id="kevink" style="margin:20px 0 0 0; display:none;">
</div>

</body>
-------------------------------------------------------------------

Gibble

5:49 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Change type="application/javascript" to "text/javascript"

Even though application/javascript is the new standard, IE doesn't recognize it.

see:
[w3schools.com...]

[edited by: Gibble at 5:50 pm (utc) on Feb. 26, 2009]

kevinkp7

5:57 pm on Feb 26, 2009 (gmt 0)

10+ Year Member



Thanks! That did it. Oh man what a hassle that's been - I really appreciate it.

Gibble

6:57 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



np, took me a while to see it too