Author | Topic |
Location: Bris-vague-us
Registered: October 2002
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 22:32
|
|
Norbie wrote on Thu, 08 September 2005 23:44 | I
He wanted a button - not a link, and not a link that looks like a button, but an actual button.
|
He wanted a button, but his assignment is to link two web pages. His interpretation of the task at hand was incorrect, hence why I felt the need to set the record straight before another person starting adding garbage code to the web
Ok, you want a form that links to another page? sure...
<?php
if(isset($_POST['target']))
header('Location:'.$_POST['target']);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd&q uot;>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-au">
<title>Google Page Jump</title>
<script type="text/javascript">
function pageJump(id) {
var form, targURL;
form = document.getElementById(id);
targURL = form.getElementsByTagName('input')[0].value;
window.location = targURL;
return false;
}
</script>
<style type="text/css"
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="pJump" onsubmit="return pageJump('pJump');" >
<fieldset>
<legend>Google Jump</legend>
<input type="hidden" name="target" value="http://google.com/">
<input type="submit" value="Go to Google">
</fieldset>
</form>
</body>
</html>
That page requires a PHP server to function correctly, but it will work in every browser ever made. Change the input type="hidden" to type="text" and suddenly the user can enter in the address they want to visit. Hoorah.
Norbie: Event handlers do not require the javascript: protocol. In fact, the javascript: protocol was never part of a formal standard and as such is merely a "hack that still works".
You should be attaching events using DOM2 methods. Have a search on 'unobtrusive scripting' if you want more details
|
|
|
| Subject | Poster | Date |
|
Anyone know javascript?
|
Smokey228 | Wed, 07 September 2005 06:47 |
|
Re: Anyone know javascript?
|
ehendrikd | Wed, 07 September 2005 06:59 |
|
Re: Anyone know javascript?
|
Norbie | Wed, 07 September 2005 07:00 |
|
Re: Anyone know javascript?
|
Shraka | Wed, 07 September 2005 07:04 |
|
Re: Anyone know javascript?
|
Vee_469 | Wed, 07 September 2005 14:42 |
|
Re: Anyone know javascript?
|
Norbie | Wed, 07 September 2005 23:52 |
|
Re: Anyone know javascript?
|
Shraka | Thu, 08 September 2005 00:57 |
|
Re: Anyone know javascript?
|
Vee_469 | Thu, 08 September 2005 04:47 |
|
Re: Anyone know javascript?
|
Norbie | Thu, 08 September 2005 01:44 |
|
Re: Anyone know javascript?
|
MR. 2 | Thu, 08 September 2005 02:03 |
|
Re: Anyone know javascript?
|
Shraka | Thu, 08 September 2005 03:11 |
|
Re: Anyone know javascript?
|
Mx73_LuXoBarge | Thu, 08 September 2005 10:48 |
|
Re: Anyone know javascript?
|
Norbie | Thu, 08 September 2005 13:44 |
|
Re: Anyone know javascript?
|
thechuckster | Thu, 08 September 2005 14:24 |
|
Re: Anyone know javascript?
|
thu187 | Thu, 08 September 2005 16:12 |
|
Re: Anyone know javascript?
|
Mx73_LuXoBarge | Thu, 08 September 2005 23:07 |
|
Re: Anyone know javascript?
|
Mx73_LuXoBarge | Thu, 08 September 2005 22:32 |