There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen boot bsod computer connection crash css dell display driver drivers email error ethernet excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem router slow software sound trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Solved: Creating a pop-up with JavaScript


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
n0sferatu's Avatar
Member with 56 posts.
 
Join Date: Jun 2004
Location: Australia
Experience: Intermediate
14-Oct-2006, 12:52 AM #1
Solved: Creating a pop-up with JavaScript
Am trying to follow these instructions, but it doesn't seem to be working. Everytime I click on the links on my page, I just get an error on page.

http://www.yourhtmlsource.com/javasc...ingtothewindow

Below is the code for the 'test' page I'm trying to get it working in... can anyone help me out?

<html>
<head>
<script type="text/javascript">
function details1()
{
var generator=window.open('','name','height=400,width=500');

generator.document.write('<html><head><title>Popup</title>');
generator.document.write('<link rel="stylesheet" href="style.css">');
generator.document.write('</head><body>');
generator.document.write('<p>Here are more details for the 1st menu item.</p>');
generator.document.write('<p><a href="javascript:self.close()">
Close</a> the popup.</p>');
generator.document.write('</body></html>');
generator.document.close();
}
function details2()
{
var generator=window.open('','name','height=400,width=500');

generator.document.write('<html><head><title>Popup</title>');
generator.document.write('<link rel="stylesheet" href="style.css">');
generator.document.write('</head><body>');
generator.document.write('<p>Here are more details for the 2nd menu item.</p>');
generator.document.write('<p><a href="javascript:self.close()">
Close</a> the popup.</p>');
generator.document.write('</body></html>');
generator.document.close();
}
</script>
</head>
<body>
<p><strong>Menu Item 1</strong></p>
<p>Here is a short description of the item</p>
<p><a href="javascript:details1();">Click here for more details</a></p>
<p><strong>Menu Item 2 </strong></p>
<p>Here is a short description of the item</p>
<p><a href="javascript:details2();">Click here for more details</a></p>
</body>
</html>
thecoalman's Avatar
Computer Specs
Distinguished Member with 2,503 posts.
 
Join Date: Mar 2006
Location: Pennsylvania
Experience: What's the shiny red button for? <click>
14-Oct-2006, 03:05 AM #2
This:

Code:
generator.document.write('<p><a href="javascript:self.close()">
Close</a> the popup.</p>');
Has to be on it's own line:

Code:
generator.document.write('<p><a href="javascript:self.close()">Close</a> the popup.</p>');
n0sferatu's Avatar
Member with 56 posts.
 
Join Date: Jun 2004
Location: Australia
Experience: Intermediate
14-Oct-2006, 03:28 AM #3
Thanks - glad it was so simple to fix!
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:38 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.