Solved

javascript redirect

Posted on 2007-04-03
8
436 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Date on a table 16 34
Given a github repo find email address of all collaborators in that repo 1 32
links not working 2 26
Table style position to the left 8 25
This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

756 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