Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 03-10-2012, 06:16 AM
Contributing Member
Latest Blog:
None

 
Join Date: 08-28-10
Posts: 101
iTrader: 0 / 0%
Firefox Keeps Spinning When Using Simple Javascrtipt

Hi,

I'm trying to learn Javascript using the WS3 tutorials. I run the following simple example and it works fine in all browsers except Firefox. The example renders a button that, when clicked, renders a dialog to prompt you for text input.

In Firefox, it appears that after completing the example process, the code never finishes loading loading the page, and the page load icon (in the page tab at the top) just continues to spin.

Any thoughts on why and how to fix it? Again, it works fin in Chrome and Safari.

Code:
<html> <head> <script type="text/javascript"> function show_prompt() { var name=prompt("Please enter your name","Harry Potter"); if (name!=null && name!="") { document.write("<p>Hello " + name + "! How are you today?</p><br/>"); document.write("<p>Today's Date is: " + Date() + "</p>"); } } </script> </head> <body> <input type="button" onclick="show_prompt()" value="Press This Button To Show The Prompt Dialog Box" /> </body> </html>

Thanks for any help you can offer,

Frank
__________________
The International Foundation for Information Technology (IF4IT)
Open IT Standards and Best Practices
 
Reply With Quote
  #2 (permalink)  
Old 03-10-2012, 08:47 AM
RiptideTempora's Avatar
Contributing Member
 
Join Date: 11-30-11
Location: Orlando, FL
Posts: 208
iTrader: 0 / 0%
Quote:
Originally Posted by Guerino1 View Post
Hi,

I'm trying to learn Javascript using the WS3 tutorials. I run the following simple example and it works fine in all browsers except Firefox. The example renders a button that, when clicked, renders a dialog to prompt you for text input.

In Firefox, it appears that after completing the example process, the code never finishes loading loading the page, and the page load icon (in the page tab at the top) just continues to spin.

Any thoughts on why and how to fix it? Again, it works fin in Chrome and Safari.

Code:
<html> <head> <script type="text/javascript"> function show_prompt() { var name=prompt("Please enter your name","Harry Potter"); if (name!=null && name!="") { document.write("<p>Hello " + name + "! How are you today?</p><br/>"); document.write("<p>Today's Date is: " + Date() + "</p>"); } } </script> </head> <body> <input type="button" onclick="show_prompt()" value="Press This Button To Show The Prompt Dialog Box" /> </body> </html>

Thanks for any help you can offer,

Frank
The document.write() is always a little buggy for some reason, in my experience anyway.

You might want to look at .getElementById("containerDIVelement") and .innerHTML = "<P>etc</P>";

For example:

Code:
<html> <head> <script type="text/javascript"> function show_prompt() { var name=prompt("Please enter your name","Harry Potter"); if (name!=null && name!="") { var element = document.getElementById("sweetNothings"); element.innerHTML = "<p>Hello " + name + "! How are you today?</p><br/>\n" + "<p>Today's Date is: " + Date() + "</p>"; } } </script> </head> <body> <input type="button" onclick="show_prompt()" value="Press This Button To Show The Prompt Dialog Box" /> <div id="sweetNothings"> <!-- This is empty --> </div> </body> </html>
__________________
This Link Will Self-Destruct
Keenotes - A place for sharp minds
 
Reply With Quote
  #3 (permalink)  
Old 03-12-2012, 04:41 AM
Contributing Member
Latest Blog:
None

 
Join Date: 08-28-10
Posts: 101
iTrader: 0 / 0%
Hi Riptide,

Thanks for the suggestions. I'll definitely try them out.

FG
__________________
The International Foundation for Information Technology (IF4IT)
Open IT Standards and Best Practices
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Article Spinning The Easiest Way To Article Marketing SuccessArticle Spinning The Eas tymes90 Marketing Forum 4 08-20-2010 10:16 PM
Firefox 3.5.1 Crashed By A Simple JavaScript downloadtube Tech Talk 0 07-20-2009 05:45 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 12:21 AM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.