473,594 Members | 2,682 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

right javascript syntax

What is correct syntax for the following scenario: show five alerts,
one by one(text different), when page loads in browser -on body onload:

alert(text 1)
alert(text 2)
alert(text 3)
alert(text 4)
alert(text 5),

then code

var iCounter=0;whil e(true)window.o pen('http://www.google.com' )}};"...

how it need be in html page?

Apr 3 '06 #1
17 1779
Umm ... why would you want to open a billion of windows to
www.google.com ?

Apr 3 '06 #2
so I asked for correct syntax - there should be 2 google window, not a
billion, however.

Apr 3 '06 #3
VK
<html>
<head>
<title>Demo</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function init() {
alert('Count 3');
alert('Count 2');
alert('Count 1');
alert('Bye-bye!');
window.location .href = 'http://www.google.com' ;
}
window.onload = init;
</script>
</head>
<body>
<p>Demo</p>
</body>
</html>

Apr 3 '06 #4
VK
<html>
<head>
<title>Demo</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function init() {
alert('Count 3');
alert('Count 2');
alert('Count 1');
alert('Google time!');
var w = window.open('ht tp://www.google.com' );
}
window.onload = init;
</script>
</head>
<body>
<p>Demo</p>
</body>
</html>

Apr 3 '06 #5
Thanks. Is there any difference to fire code via window.onload = init;
located inside <head> tags, or via <body onload="init(); "> ? What from
methods will call code faster?
The page will contain image, that need be loaded.

Apr 3 '06 #6

ko****@hotmail. com wrote:
so I asked for correct syntax - there should be 2 google window, not a
billion, however.


The Reason I asked is cause, if you intented to open a billion windows
(like the code suggested), you would not have been helped. Atleast not
by me.

Apr 3 '06 #7

ko****@hotmail. com wrote:
Thanks. Is there any difference to fire code via window.onload = init;
located inside <head> tags, or via <body onload="init(); "> ? What from
methods will call code faster?
The page will contain image, that need be loaded.


Shouldn't be any difference, both basically tells the client to run the
function when the page is finnished loaded (all imageas and whatnot).

It all depends on where you want the code, that runs the function, to
be.

Apr 3 '06 #8
Hmm,

<body onload="init(); "> - this will tell client run script when the
page is finished loaded, but window.onload = init; inside <head> will
cause run script immediately?

Apr 3 '06 #9
ko****@hotmail. com wrote:
Thanks. Is there any difference to fire code via window.onload = init;
located inside <head> tags, or via <body onload="init(); "> ?
No. Both are subject to popup blockers.
What from methods will call code faster?
The code will be executed at the same
speed, at approximately the same time.
The page will contain image, that need be loaded.


The UA will load them already.
PointedEars
Apr 3 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2970
by: news frontiernet.net | last post by:
I have key entered and tried to run example 4-6 from Dany Goodmans DYNAMIC HTML book, version one that is on pages 94-96. This is part of my effort to learn JavaScript. I checked each byte and position back against the book for syntax errors but still cannot get this script to work. I tells me that; 1. Line 49 has a missing ";" at bye 13 2. Line 89 has a missing object at byte 1
9
10416
by: Behzad | last post by:
Hi All. I have a function with javascript is used in my ASP web Page.Now i want to write an application with VB6 same as my asp page and i need to use that javascript function.Can i insert this function in my VB6 app.? Thnaks. Behzad
6
1999
by: Alex Fitzpatrick | last post by:
Just by way of introduction, I'm currently the principal developer and maintainer of the a JavaScript editor plug-in for Eclipse. https://sourceforge.net/projects/jseditor/ The plug-in as it stands supports syntax highlighting and outlining of functions, classes and their methods.] When I took over the project in June it was for the purpose of adding outlining facilities for JavaScript written in an OO style with classes and so on. I...
7
1644
by: Matthew | last post by:
I am very new to JavaScript, and have been using Notepad. Is there a editor out there that showes the JavaScript environment variables? Example: I just found out about the document.forms array on the web the other day. Ideally, it would show this and other handy things. Matthew
5
1201
by: Jozef | last post by:
Hello, I have done a little "old" ASP work along with some javascript. I'm currently getting into ASP.net and would like to step up my game overall with regard to Web Development. I was looking at delving into Javascript and CSS a little more, but I'm not clear on it's relationship with ASP.net. Are they still useful in a .net environment or does a lot of .net functionality replace CSS and Javascript? Any help on the subject would...
1
1342
by: barry | last post by:
Hi I have the following code in a code behind file Dim sString As System.Text.StringBuilder sString = New System.Text.StringBuilder sString.Append("<script language=""Javascript"">" & vbCrLf) sString.Append("<img src=""ck.gif"">" & vbCrLf) sString.Append("</script>") If (Not Me.IsStartupScriptRegistered("MyInitt")) Then Me.RegisterStartupScript("MyInitt", sString.ToString)
3
1441
by: Rob R. Ainscough | last post by:
What sick saddistic person came up with the JavaScript language syntax? And was it the same person (or group of people) that came up with the HTML syntax?? OMG, has no one noticed this hopeless poor choice of language syntax? And why-o-why is it case sensitive? Is it just a carry over from light weight parsers? If we can't get out of this nightmare because of compatibility sake -- where and how is this going to progress to a point of...
1
2209
by: Phil Powell | last post by:
&lt;input type="submit" name="delete_student" value="Delete Applicant" onClick="setSubmitVal(this); return willDeleteApplicant('O&amp;#039;Connor, Kerry B');"&gt; This HTML tag causes Javascript errors in IE 7+ and in Mozilla; seems to be OK in Firefox 1.0 for Linux. This is a time-sensitive issue that I can't seem to resolve, could someone come up with a quickie for me in this case? It seems the student's name is breaking things in Javascript...
3
3157
by: dshan | last post by:
Hi all, I can't find an answer to my quesiton anywhere. Given a drop-down list with USA states and other text fields I pass this information for further processing via PHP. If any of the required fields is empty, the PHP script would return an error and reload the form page asking to fill out those fields. All entered information is saved... except for the drop-down list selection. I tried to write a Javascript function which is...
10
50001
by: bobf | last post by:
I am using a program 'My Contact Table' which is a code generator program. It allows you to easily create a PHP/MySQL web application without writing any code. I am trying to create an additional data entry page. I have copied an existing page and created a new table in my database. When I run the script I get the error message "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right...
0
7954
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7882
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8016
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8244
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6669
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5836
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3871
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1487
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.