8 Replies - 2258 Views - Last Post: 14 May 2011 - 06:38 AM

#1 omnicoder   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 05-May 11

Trying to make a pop-up window

Posted 12 May 2011 - 02:54 PM

I am trying to make a pop up box that does not have the toolbar, status line, and does not say Java application at top of Pop up box. Here is how I wrote the code. It did not work. Please help?

<html>
<head>
<title>Popup window</title

<script> language="javascript" type="text/javascript">
                 SmallWin = window.open("","small","width=100,height=120,toolbar=0,status=0";
</script>
<head/>
<body>

<p>
Attempting to make a pop up window.
</p>

</body>
</html>

This post has been edited by Dormilich: 12 May 2011 - 10:04 PM
Reason for edit:: please use [code] /* your code source here */ [/code] tags when posting code


Is This A Good Question/Topic? 0
  • +

Replies To: Trying to make a pop-up window

#2 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Trying to make a pop-up window

Posted 12 May 2011 - 03:22 PM

Hey.

There are three major errors in there:

  • You forget to close the </title> tag. (The end > is missing).
  • You close the <script> tag before listing the attributes for it. The type="text/javascript" should be inside it. (The language="javascript" isn't needed. I'd just remove that one.)
  • You forget the closing ) for your window.open() call.


Also, you should include a HTML Doctype. All HTML documents should have one at the very top of the document. - Otherwise the browser goes into quirks mode, which is nothing but trouble.

I would suggest HTML4 Transitional:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">


Was This Post Helpful? 0
  • +
  • -

#3 omnicoder   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 05-May 11

Re: Trying to make a pop-up window

Posted 12 May 2011 - 05:23 PM

View PostAtli, on 12 May 2011 - 03:22 PM, said:

Hey.

There are three major errors in there:

  • You forget to close the </title> tag. (The end > is missing).
  • You close the <script> tag before listing the attributes for it. The type="text/javascript" should be inside it. (The language="javascript" isn't needed. I'd just remove that one.)
  • You forget the closing ) for your window.open() call.


Also, you should include a HTML Doctype. All HTML documents should have one at the very top of the document. - Otherwise the browser goes into quirks mode, which is nothing but trouble.

I would suggest HTML4 Transitional:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">



Please excuse my ignorance. I am in my infancy stage learning Javascript. What specifically do you mean by attributes? I got the pop-up box to show up with your assistance. But, the pop-up box still had the red, yellow and green close, expand, minimize small circle buttons on the top left conner of the pop-up box. I want to remove them. I am using a Mac. I want a pop-up box that shows up like the banners and advertisement ads do when you are in the middle of looking at or leaving a web page. Again, your assistance will be greatly appreciated?
Was This Post Helpful? 0
  • +
  • -

#4 codeprada   User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 963
  • View blog
  • Posts: 2,382
  • Joined: 15-February 11

Re: Trying to make a pop-up window

Posted 12 May 2011 - 05:56 PM

Attributes are like descriptors of an element.

Example
<div id="mydiv" style="color:red"></div>

The attributes of that div element are id and style.

In your code you have
<script> language="javascript" type="text/javascript">
but the tag is closed after <script> which makes it incorrect.

To detect when a user is leaving a window you must assign a callback to the window.onunload event.

<html>
<head>
<script type="text/javascript">
function closing()
{
	alert('Goodbye');
	return false;
}
window.onunload = closing;
</script>
</head>
<body>
<a href="http://www.google.com">Google</a>
</body>
</html>

Was This Post Helpful? 0
  • +
  • -

#5 omnicoder   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 05-May 11

Re: Trying to make a pop-up window

Posted 13 May 2011 - 08:54 AM

View Postcodeprada, on 12 May 2011 - 05:56 PM, said:

Attributes are like descriptors of an element.

Example
<div id="mydiv" style="color:red"></div>

The attributes of that div element are id and style.

In your code you have
<script> language="javascript" type="text/javascript">
but the tag is closed after <script> which makes it incorrect.

To detect when a user is leaving a window you must assign a callback to the window.onunload event.

<html>
<head>
<script type="text/javascript">
function closing()
{
	alert('Goodbye');
	return false;
}
window.onunload = closing;
</script>
</head>
<body>
<a href="http://www.google.com">Google</a>
</body>
</html>


Thanks for the assistance. I understood how to do everything you posted. I am trying to prefect my coding when It comes to attributes thought. I am trying to make pop up boxes that look and function like the example in this link– http://www.youtube.c...feature=related, if you don't mind viewing. I want to make pop up boxes programming totally in Javascript. Can that be done? I am trying to improve my programming skills. Without using third party programs.
Was This Post Helpful? 0
  • +
  • -

#6 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Trying to make a pop-up window

Posted 13 May 2011 - 12:59 PM

So what you want is not really a new window to pop up, but an element on your page to be added and put on top of the rest of the page. That can be done fairly easily using Javascript and CSS.

Take this for example: Javascript PopUp Example
It's as simple as I can make it. Should be a good place to start from. You can mess with the CSS to change the appearance, and expand the Javascript code to add more stuff to the box.

You may want to read up on the document.createElement, appendChild and removeChild Javascript methods. Those are the once you use to create, add and remove new elements to your page.

This post has been edited by Atli: 13 May 2011 - 01:00 PM

Was This Post Helpful? 0
  • +
  • -

#7 omnicoder   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 05-May 11

Re: Trying to make a pop-up window

Posted 13 May 2011 - 04:18 PM

View PostAtli, on 13 May 2011 - 12:59 PM, said:

So what you want is not really a new window to pop up, but an element on your page to be added and put on top of the rest of the page. That can be done fairly easily using Javascript and CSS.

Take this for example: Javascript PopUp Example
It's as simple as I can make it. Should be a good place to start from. You can mess with the CSS to change the appearance, and expand the Javascript code to add more stuff to the box.

You may want to read up on the document.createElement, appendChild and removeChild Javascript methods. Those are the once you use to create, add and remove new elements to your page.
That is what I am trying to do. Put and element on top of the page. But, I want it to automatically appear after the page has been open for a certain amount of time. For example, five second after the page has loaded up. I don't want to have to click on any buttons for the element to appear on top of the rest of the page. Could you suggest a web site for this information? Any assistance with greatly be appreciated?
Was This Post Helpful? 0
  • +
  • -

#8 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Trying to make a pop-up window

Posted 13 May 2011 - 05:35 PM

There are several ways to have code execute when the page loads. A popular one is the window.onload event handler. It executes the specified function after everything on the page has been loaded.

And you can use the window.setTimeout method to execute code after a specific interval.
Was This Post Helpful? 0
  • +
  • -

#9 omnicoder   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 05-May 11

Re: Trying to make a pop-up window

Posted 14 May 2011 - 06:38 AM

View PostAtli, on 13 May 2011 - 05:35 PM, said:

There are several ways to have code execute when the page loads. A popular one is the window.onload event handler. It executes the specified function after everything on the page has been loaded.

And you can use the window.setTimeout method to execute code after a specific interval.
Thank you for the assistance.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1