Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   JavaScript and Client-Side Browser Scripting (http://www.programmingforums.org/forum23.html)
-   -   Java Script Button (http://www.programmingforums.org/showthread.php?t=4496)

crawforddavid2006 Jun 17th, 2005 6:41 PM

Java Script Button
 
what is the code for a button with a link in java script?

crawforddavid2006 Jun 17th, 2005 9:46 PM

Is it even possible to make a button with a hyperlink in java script?

CrAzY_J Jun 18th, 2005 12:50 AM

:

<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>


Cerulean Jun 25th, 2005 11:15 AM

Will that run? iHateU() isn't defined 'till after it is referenced?

Ooble Jun 25th, 2005 3:06 PM

It won't.

DaWei Jun 26th, 2005 8:12 PM

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.

Cerulean Jun 27th, 2005 9:39 AM

*nods*

Ooble Jun 27th, 2005 10:24 AM

I would personally just do this:
:

<form action="http://www.example.com/" method="post">
    <div><input type="submit" value="Go!" /></div>
</form>


tempest Jun 27th, 2005 3:20 PM

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]

Navid Jun 27th, 2005 4:02 PM

This could be done in just html

HTML:
:

<form>
<input type="button" value="Click here" onClick="parent.location='http://www.programmingforums.org'">
</form>



All times are GMT -5. The time now is 2:19 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC