Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > HTML and JavaScript

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-12-2004, 12:11 PM   #1
Gideon
Registered User
 
Join Date: Aug 2004
Posts: 13
Unhappy JavaScript problem??Someone hlp


cud somwonw help me here.
This JavaScript code is'nt working.I am doing a tute on JavaScript and everytime a try an exercise it fails.So i jus give up the home work and move on....
anyway now i got really fed up and came here

ps. this code was made in dreamweaver mx and many times JavaScript fuctions from many sites i visit dont work, whereas many sites' codes work well.( i hav internet explorer 6.0.2600.0000)an' theres the original htm file attached

Thanx
gidoen

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Kool Browser</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--hide me
function fixUrl (the_url)
{
            var the_url = the_url.toLowerCase():
			var first_seven = the_url.substring(0,7);
			if (first_seven != 'http://') 
			{
			the_url = 'http://'+ the_url
			}
			return the_url
}
function addToFav ();
{
             var url = prompt("Wats the url??", "http://");
			 if ((url == "") && (url == null)) { 
			  alert("Thats not a url, LOSER"); 
			 } else {
			 var good_url = fixUrl(url);
			 var the_fav = window.document.fav_form.favorites;
			 var num_option = the_fav.options.length;
			 var new_option = new Option;
             new_option.text = good_url;
			 the_fav.options[num_options]= new_option;
			 }
}		
function goThere ()
{      
               var url = window.document.fav_form.favorites.options[url.selectedIndex].text;
               var good_url = fixUrl(url);
			   new_window = window.open(url, "window_one");
}
// show me-->
</script>
</head>
<body>
<p align="center"><font color="#990000" size="5" face="Comic Sans MS">KoolBrowser 
  2000 </font></p>
<form name="fav_form">
  <font size="4" face="Comic Sans MS">The Favorites Menu</font> 
  <select name="favorites" size="1" onChange="gothere();">
    <option>Pull Down 2 Go 2 ur Fav. Site</option>
    <option>http://www.actionscript.com</option>
    <option>http://www.flashkit.com</option>
    <option>http://www.webmonkey.weird.com</option>
    <option>http://www.nicksplat.com</option>
  </select>
  <a href="#" onClick="goThere(); return false;">Add To Favorites </a> 
</form>
 
<p align="center"><font size="2">(Click the Add2 Fav. Btn to add to ur fav menu)</font></p>
<hr>
<p><font face="Comic Sans MS">This a Typical JavaScript webpage.It was contructed 
  by me Gideon.</font></p>
</body>
</html>
Attached Files
File Type: zip KoolBrowser.zip (1.0 KB, 176 views)
Gideon is offline   Reply With Quote
Old 09-17-2004, 05:05 PM   #2
programmer_neo
Registered User
 
Join Date: Aug 2004
Location: Chicago, IL
Posts: 22
Default

I cleaned up your code and it works now.
Compare mine to yours.
You had some semicolons, where none should be.
You misnamed your functions.

Suggestion:A great way to debug you javascript code is actually to use
Netscape. It has a better javascript debugger than IE.
(One of it's only advantages.)

Just run your page, then type in the url line ... javacsript:
(remember the colon) It launches the debugger and tells you what line is bad
and a possible solution.

Code:
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Kool Browser</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--hide me
function fixUrl (the_url)
{
            the_url = the_url.toLowerCase();
			var first_seven = the_url.substring(0,7);
			if (first_seven != "http://") 
			{
			the_url = "http://"+ the_url
			}
			return the_url
}
function addToFav () 
{
             var url = prompt("Wats the url??", "http://");
			 if ((url == "") && (url == null)) { 
			  alert("Thats not a url, LOSER"); 
			 } else {
			 var good_url = fixUrl(url);
			 var the_fav = window.document.fav_form.favorites;
			 var num_option = the_fav.options.length;
			 var new_option = new Option;
             new_option.text = good_url;
			 the_fav.options[num_options]= new_option;
			 }
}		
function goThere (myUrl)
{      
	
               var good_url = fixUrl(myUrl);
			   new_window = window.open(good_url, "window_one");
}
// show me-->
</script>
</head>
<body>
<p align="center"><font color="#990000" size="5" face="Comic Sans MS">KoolBrowser 
  2000 </font></p>
<form name="fav_form">
  <font size="4" face="Comic Sans MS">The Favorites Menu</font> 
  <select name="favorites" size="1" onChange="goThere(this.value);">
    <option>Pull Down 2 Go 2 ur Fav. Site</option>
    <option>http://www.actionscript.com</option>
    <option>http://www.flashkit.com</option>
    <option>http://www.webmonkey.weird.com</option>
    <option>http://www.nicksplat.com</option>
  </select>
  <a href="#" onClick="goThere(); return false;">Add To Favorites </a> 
</form>
 
<p align="center"><font size="2">(Click the Add2 Fav. Btn to add to ur fav menu)</font></p>
<hr>
<p><font face="Comic Sans MS">This a Typical JavaScript webpage.It was contructed 
  by me Gideon.</font></p>
</body>
</html>
programmer_neo is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:48 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.