Author | Topic |
Location: Sydney
Registered: January 2005
|
Anyone know javascript?
|
Wed, 07 September 2005 06:47
|
|
i got this assignment, and i gotta link one site with another one. now atm, its all from the local hard drive. if i can work that out the rest should be simple.
my problem is, im trying to use a button to link the websites, but i cant seem to get the button to work.
this is wat i got so far.
<form action="www.google.com" method="get"
enctype="application/x-www-form-urlencoded&qu ot;>
<p><button type="button">Order form
</button></p>
</form>
have i missed sumfin, or not dun sumfin right? any help would be appreciated.
thanks, jason
|
|
|
Location: ballarat
Registered: April 2003
|
Re: Anyone know javascript?
|
Wed, 07 September 2005 06:59
|
|
Smokey228 wrote on Wed, 07 September 2005 16:47 | i got this assignment, and i gotta link one site with another one. now atm, its all from the local hard drive. if i can work that out the rest should be simple.
my problem is, im trying to use a button to link the websites, but i cant seem to get the button to work.
this is wat i got so far.
<form action="www.google.com" method="get"
enctype="application/x-www-form-urlencoded&am p;qu ot;>
<p><button type="button">Order form
</button></p>
</form>
have i missed sumfin, or not dun sumfin right? any help would be appreciated.
thanks, jason
|
this isnt javascript, just html. i dont want to do your homework for your, but here is a clue:
look at this for your button
http://www.w3.org/TR/REC-html40/interact/forms.htm l#edef-INPUT
|
|
|
Location: Brisbane
Registered: May 2002
|
Re: Anyone know javascript?
|
Wed, 07 September 2005 07:00
|
|
Are you trying to navigate to a different site using a button? If so, you don't use a form. Something like this will do the trick:
<input type='button' onclick='javascript:window.location=http://www.goo gle.com/' value='Click here'>
|
|
|
Location: Melbourne
Registered: November 2003
|
|
|
Registered: November 2004
|
Re: Anyone know javascript?
|
Wed, 07 September 2005 14:42
|
|
Norbie wrote on Wed, 07 September 2005 15:00 |
<input type='button' onclick='javascript:window.location=http://www.goo gle.com/' value='Click here'>
|
<input type='button' onclick='location=http://www.goo gle.com/' value='Click here'>
Should work too, no?
- Vee
|
|
|
Location: Brisbane
Registered: May 2002
|
Re: Anyone know javascript?
|
Wed, 07 September 2005 23:52
|
|
It might work on some browsers (if the "window" object is assumed to be the default), but it's less concise. For the sake of 7 characters I'd do it my way.
|
|
|
Location: Melbourne
Registered: November 2003
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 00:57
|
|
Norbie wrote on Thu, 08 September 2005 09:52 | It might work on some browsers (if the "window" object is assumed to be the default), but it's less concise. For the sake of 7 characters I'd do it my way.
|
For the sake of it working on browsers that don't have Java, i'd do it my way.
|
|
|
Location: Brisbane
Registered: May 2002
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 01:44
|
|
Who the hell uses browsers with no javascript support any more? I don't believe in designing sites to cater for 0.01% of the online population.
|
|
|
Location: Parramatta
Registered: July 2002
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 02:03
|
|
Quote: | For the sake of it working on browsers that don't have Java, i'd do it my way
|
java and javascript are different dont confuse them.
|
|
|
Location: Melbourne
Registered: November 2003
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 03:11
|
|
MR. 2 wrote on Thu, 08 September 2005 12:03 |
Quote: | For the sake of it working on browsers that don't have Java, i'd do it my way
|
java and javascript are different dont confuse them.
|
Programing scum.
And Norby, I design stuff that doesn't work in anything but the latest version of IE, so I see your point. If someone wants to see my page, they can bloodywell use whatever I design the page for.
|
|
|
Registered: November 2004
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 04:47
|
|
Norbie wrote on Thu, 08 September 2005 07:52 | It might work on some browsers (if the "window" object is assumed to be the default), but it's less concise. For the sake of 7 characters I'd do it my way.
|
Good point
- Vee
|
|
|
Location: Bris-vague-us
Registered: October 2002
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 10:48
|
|
I realise that this is not the place for such discussion (nor such a question...anyhoo), but there is a fundemental flaw in every option put forth...
Forms are not for navigation, ever. This is one of the key principles laid down in Tim Berners Lee's orignal design for the 'world wide web', written in 1982.
First of all, here's the answer to the original request:
<a href="fileName.html" title="Go to next page">Clickity click!</a>
If you want it to look like a button, try this: (google 'CSS buttons' for more)
<a href="fileName.html" style="border:2px outset #ccc;padding:3px 2px; background:#aaa; color:#000;">Clickity click!</a>
As for the forms (<form>) vs. links (<a>) thing, the reason is quite simple. Forms are designed to accept and relay information entered by a person. Links are designed to be the sole navigation mechanism of the world wide web and as such, the web has been designed around the above premise. All 'bots' (computer controlled browsers) use links to navigate between pages. This is very important as without search bots indexing your site, it will never show up on Google, Yahoo or any of the search sites. Whilst having people link to your site will get the home page listed with search engines, if they're unable to scan deeper you will be given a VERY low search rank due to lack of content.
There are many more reasons, but I think that'll do considering this is a automotive forum
Shraka |
I design stuff that doesn't work in anything but the latest version of IE, so I see your point.
|
Do you actually get paid for purposely excluding customers from your clients' sites?
Sorry, I just can't stand such an ignorant attitude
[Updated on: Thu, 08 September 2005 10:51]
|
|
|
Location: Brisbane
Registered: May 2002
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 13:44
|
|
I understand what you're saying and I agree, but your solution doesn't answer the question which was asked.
Smokey228 wrote on Wed, 07 September 2005 16:47 | my problem is, im trying to use a button to link the websites, but i cant seem to get the button to work.
|
He wanted a button - not a link, and not a link that looks like a button, but an actual button.
|
|
|
Location: Brisbane
Registered: February 2003
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 14:24
|
|
why not do what this forum does?
like the buttons to send a PM or an email to the person posting a message? an image that looks like button (e.g.)
<a href=URL><img alt=description src=URL border=0></a>
ok ... so it cheats (because it's not a real form element) but it works - and you can be a lazy web developer (like Shraka) yet still make codes that works in any web browser not just iExploder.
|
|
|
Location: Sydney
Registered: September 2004
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 16:12
|
|
thechuckster wrote on Fri, 09 September 2005 00:24 | why not do what this forum does?
like the buttons to send a PM or an email to the person posting a message? an image that looks like button (e.g.)
<a href=URL><img alt=description src=URL border=0></a>
|
Because buttons are built into windows thus you do not have to download them thus the site will load quicker.
|
|
|
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
|
|
|
Location: Bris-vague-us
Registered: October 2002
|
Re: Anyone know javascript?
|
Thu, 08 September 2005 23:07
|
|
thu187 wrote on Fri, 09 September 2005 02:12 |
Because buttons are built into windows thus you do not have to download them thus the site will load quicker.
|
Correct. More importantly, different browsers and different OS's have very different native form controls (eg: glass buttons on OSX Safari). Each user is accustomed to the default display of form elements on their browser and are subconsiously tuned into recognising them.
Following established visual and interaction conventions is the single most important aspect of user interface design. That is why we try to use standard form controls instead of javascript powered images and real links instead of javascript powered forms. It's not because javascript is bad (it's not, when used responsibly), it's because the user has preconcieved (and CORRECT) nnnotions of what action that element should cause.
If any of you guys want to go into more detail about this stuff, I'm a staff member @ codingforums.com and I'm also a core member of the Web Standards Group (http://webstandardsgroup.org) -- an international group started in Australia with meetings in Bris, Sydney, Melbourne, Perth and Wellington.
If you're looking for specific help with web stuff, PM me at codingforums with your question and I'll help you out
(just make sure to mention you're from toymods )
cheers,
Andrew.
[Updated on: Thu, 08 September 2005 23:14]
|
|
|