Solved

javascript redirect

Posted on 2007-04-03
8
435 Views
Last Modified: 2012-05-05
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.gif" id="button-refresh" class="button right" name="refresh" value="Refresh" alt="Refresh" title="Refresh" onmouseover="this.style.backgroundPosition='left bottom'" onmouseout="this.style.backgroundPosition='left top'"onClick="location.href='macresv.html'" />
0
Comment
Question by:coolispaul
8 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 18842368
Hello coolispaul

try

onClick="window.location.href='macresv.html'"

HTH

!i!
0
 
LVL 29

Expert Comment

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

Expert Comment

by:flipz
ID: 18842396
<img src="images/transparent.gif" id="button-refresh" class="button right" name="refresh"  alt="Refresh" title="Refresh" onmouseover="this.style.backgroundPosition='left bottom'" onmouseout="this.style.backgroundPosition='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="this.style.backgroundPosition='left top'" onClick="location.href='macresv.html'"
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:coolispaul
ID: 18842447
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"

0
 
LVL 11

Expert Comment

by:flipz
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".
0
 

Author Comment

by:coolispaul
ID: 18842547
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?
0
 
LVL 1

Accepted Solution

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

Computer101
EE Admin
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

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.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

832 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