onclick works in FF but not in IE7

S

sisqorap

Hi all,

I have a problem with a dynamic made onclick and I'm trying to figure
it out with a little page but I can't get it to work in IE7. Can
somebody help me out?

This is the code:
<html>
<head>
<script language="Javascript" type="text/javascript">
function Loading(){
document.getElementById('hallo').setAttribute("onClick","window.open('http://
www.google.be')");
}
</script>
</head>
<body onLoad='javascript:Loading();'>
<div id='hallo'>HAAALLOOO</div>
</body>
</html>

Greetz
 
D

David Mark

Hi all,

I have a problem with a dynamic made onclick and I'm trying to figure
it out with a little page but I can't get it to work in IE7. Can
somebody help me out?

This is the code:

Add a doctype.
<html>
<head>
<script language="Javascript" type="text/javascript">

Lose the language attribute.
function Loading(){
document.getElementById('hallo').setAttribute("onClick","window.open('http:­//www.google.be')");}

The get/setAttribute methods are broken as designed in IE. Set the
onclick property to an anonymous function instead.
</script>
</head>
<body onLoad='javascript:Loading();'>

Lose the "javascript:" prefix.

[snip]
 
S

sisqorap

Add a doctype.


Lose the language attribute.


The get/setAttribute methods are broken as designed in IE. Set the
onclick property to an anonymous function instead.
What do you mean with this one?
</script>
</head>
<body onLoad='javascript:Loading();'>

Lose the "javascript:" prefix.

[snip]

I've did all the rest except for the anonymous function and it didn't
work yet on IE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top