[javascript] What is wrong with this? (see thread)

Glaanieboy

OSNN Veteran Addict
Joined
6 Mar 2002
Messages
2,628
Code:
<html>
 <head>
  <title>Javascript Test</title>
  <script language="text/javascript">
  function jumpTo(confirm_text,alert_text,url){
    if(confirm_text){
      if(confirm(confirm_text)){
        location.href = url;
      }else{
        if(alert_text){
          alert(alert_text);
        }
      }
    }
  }
  </script>
 </head>
 <body>
  <a href="javascript:void(0);" onClick="javascript:jumpTo('Confirm this','ALERT!','http://www.whatismyip.com');">Click me</a>
 </body>
</html>

This piece of HTML/javascript should display a text in a confirm dialog and when canceled it should display the alert box. But when I click the 'Click me' link, it does nothing. What is wrong with this piece of code?
 

j79zlr

Glaanies script monkey
Political Access
Joined
16 Feb 2003
Messages
2,725
OK, Glaanie you had me stumped so I knew it was something simple

<script language="text/javascript">

to

<script type="text/javascript">

Took me 20 minutes to figure that one out :D
 

Glaanieboy

OSNN Veteran Addict
Joined
6 Mar 2002
Messages
2,628
Ah I see how I made the mistake. I use tsWebeditor for my webediting tasks and when I typed '<script ' a pulldown menu appeared with two options, 'language' and 'src'. I am still wondering why it didn't include 'type'. btw what does 'language' do then?
 

albybum

Penguin Rancher
Joined
9 Feb 2002
Messages
281
Language was how browsers determined the type of the script in the past, but it is deprecated now. Type is the more current way to specify a script language type.

It is good practice to have both as anyone with an old or limited browser may only look for a type attribute. With the language attributeyou can set specific versions of languages for your browser to use. Say you have a script that only works with JavaScript 1.1, you would put language="JavaScript1.1"

<script type="text/javascript" language="javascript">

[edit] jeez you people are quick on the draw. Was seconds late.
 

Members online

No members online now.

Latest profile posts

Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.
Terrahertz wrote on Electronic Punk's profile.
Yo fellas!
Electronic Punk wrote on Sazar's profile.
Where are you buddy?
Perris Calderon wrote on Electronic Punk's profile.
Hey EP! All good with me, applying for Microsoft MVP right now, should have done this a while ago.

Notifications don't work, I only found your response by coming back to hunt up some threads, if you want, give me your email address so we can keep in touch easier!
Perris Calderon wrote on Electronic Punk's profile.
EP, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there!

Forum statistics

Threads
61,997
Messages
673,411
Members
5,589
Latest member
miankuttabila