![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
what is the code for a button with a link in java script?
Last edited by crawforddavid2006; Jun 17th, 2005 at 9:46 PM. Reason: typo |
|
|
|
|
|
#2 |
|
Expert Programmer
|
Is it even possible to make a button with a hyperlink in java script?
|
|
|
|
|
|
#3 |
|
Newbie
|
<script type='text/javascript'>
var iP=document.createElement('input');
iP.setAttribute('type','button');
iP.setAttribute('value','Rawr');
iP.onClick=iHateU();
function iHateU(){
document.location="www.pr0n.com";
}
document.body.appendChild(iP);
</script> |
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Will that run? iHateU() isn't defined 'till after it is referenced?
|
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
It won't.
|
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I didn't evaluate that code for workability. Javascript functions do not have to be declared before they're referenced. They DO have to be declared before they're invoked.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
*nods*
|
|
|
|
|
|
#8 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I would personally just do this:
<form action="http://www.example.com/" method="post">
<div><input type="submit" value="Go!" /></div>
</form>Last edited by Ooble; Jun 27th, 2005 at 4:01 PM. |
|
|
|
|
|
#9 |
|
Programming Guru
![]() |
I would use PHP and just do this...
[php] <?php // I have no idea if this is an actual site... header("Location: http://www.gaysex4u.com"); ?> [/php]
__________________
|
|
|
|
|
|
#10 |
|
Hobbyist Programmer
|
This could be done in just html
HTML: <form> <input type="button" value="Click here" onClick="parent.location='http://www.programmingforums.org'"> </form> |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|