Solved

javascript redirect

Posted on 2007-04-03
8
431 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 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

21 Experts available now in Live!

Get 1:1 Help Now