javascript redirect

Posted on 2007-04-03
Last Modified: 2012-05-05

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.gif" id="button-refresh" class="button right" name="refresh" value="Refresh" alt="Refresh" title="Refresh" onmouseover="'left bottom'" onmouseout="'left top'"onClick="location.href='macresv.html'" />
Question by:coolispaul
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 18842368
Hello coolispaul




LVL 29

Expert Comment

ID: 18842385
Also, you should add a space just before onClick, there is none at the moment...
LVL 11

Expert Comment

ID: 18842396
<img src="images/transparent.gif" id="button-refresh" class="button right" name="refresh"  alt="Refresh" title="Refresh" onmouseover="'left bottom'" onmouseout="'left top'" onClick="location.href='macresv.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="'left top'" onClick="location.href='macresv.html'"
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.


Author Comment

ID: 18842447

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"

LVL 11

Expert Comment

ID: 18842472
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".

Author Comment

ID: 18842547

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?

Accepted Solution

Computer101 earned 0 total points
ID: 19300239
PAQed with points refunded (500)

EE Admin

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JavaScript waiting 14 68
Add Context Menu Item 4 43
Having problem getting this to work 2 18
insert text field data into html script 13 22
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now