coolispaul
asked on
javascript redirect
hi,
i have an input type image with an onclick event that should redirect the page, but it doesnt work.
any ideas why? it does work if i change the type to "button" rather than "image"
<input type="image" src="images/transparent.gi f" id="button-refresh" class="button right" name="refresh" value="Refresh" alt="Refresh" title="Refresh" onmouseover="this.style.ba ckgroundPo sition='le ft bottom'" onmouseout="this.style.bac kgroundPos ition='lef t top'"onClick="location.hre f='macresv .html'" />
i have an input type image with an onclick event that should redirect the page, but it doesnt work.
any ideas why? it does work if i change the type to "button" rather than "image"
<input type="image" src="images/transparent.gi
Also, you should add a space just before onClick, there is none at the moment...
<img src="images/transparent.gi f" id="button-refresh" class="button right" name="refresh" alt="Refresh" title="Refresh" onmouseover="this.style.ba ckgroundPo sition='le ft bottom'" onmouseout="this.style.bac kgroundPos ition='lef t top'" onClick="location.href='ma cresv.html '" />
Input image? Not familiar with that one - try using img tag - you'll just need to figure out how to include the text 'Refresh' - part of the image itself would probably be best.
BTW - your script fires the onClick event fine for me in IE7 - make sure there is a space between the tag properties:
onmouseout="this.style.bac kgroundPos ition='lef t top'" onClick="location.href='ma cresv.html '"
Input image? Not familiar with that one - try using img tag - you'll just need to figure out how to include the text 'Refresh' - part of the image itself would probably be best.
BTW - your script fires the onClick event fine for me in IE7 - make sure there is a space between the tag properties:
onmouseout="this.style.bac
ASKER
hi,
none of that works unfortunately. As you say it does trigger the onclick event but the page isnt redirected. In firefox the browser says "stopped"
none of that works unfortunately. As you say it does trigger the onclick event but the page isnt redirected. In firefox the browser says "stopped"
Seems to work fine in my FF browser. Since the example you provided does not include the style - it may have problem there?? Can a style have a space in the name? Try class="buttonright".
ASKER
hi,
ive realised the problem is because its is inside a form. if you strip the from and leave it as just input it works.
i guess i will have to use form.submit or something along those lines unless you know of any other work arounds?
ive realised the problem is because its is inside a form. if you strip the from and leave it as just input it works.
i guess i will have to use form.submit or something along those lines unless you know of any other work arounds?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try
onClick="window.location.h
HTH
!i!