Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell driver drivers email error ethernet excel firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook 2007 outlook express partition problem router slow software sound trojan usb video virus vista wifi windows windows vista windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Need a lil help with java


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
twoshoes's Avatar
Member with 41 posts.
 
Join Date: Nov 2004
Experience: Intermediate
04-Mar-2008, 05:01 PM #1
Need a lil help with java
Hey guys,

As with the industry, this sites going live tomorrow and i have a problem with my image popup system.

It works fine but the client wants a close window button as well.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>

<script language="JavaScript" type="text/JavaScript">
function imgWin(url,width,height) { 
features= "width=" + width + ",height=" + height; 
newWin = window.open ('', '', features); 
pageCode = "<html><head><style type='text/css'>body {margin:0; padding:0; border:0; font-family: Arial; background-color: #cdc7bf; text-align: center;}a:link {color: #003333;font-size: 10px;} a:visited {color: #003333;font-size: 10px;} a:hover {color: #886600; font-size: 10px;}</style></head>"; 
pageCode += "<body><img src='" + url + "'><br>Close Window</body></html>"; 
newWin.document.write(pageCode); 
newWin.document.close(); 
}
</script>

</head>

<body>
<a href="scene.jpg" onclick="imgWin(this.href,'255','380'); return false;">Click!</a> <br>
<br>
I want this to work in the window:
<a href="javascript:window.close()">Close Window</a>
</body>
</html>
If you copy and paste that script it should work and I think you will get the idea of what im trying to achieve fairly simply. It seems I cant add a link into that script, anyone know of a fix or a workaround?
Sequal7's Avatar
Computer Specs
Distinguished Member with 2,369 posts.
 
Join Date: Apr 2001
Location: Around the corner!
Experience: Including today?
04-Mar-2008, 05:09 PM #2
Hello You were close, you just needed to add this
Code:
<a href=\"javascript:window.close()\">Close Window</a>
to your script for the popup;

Code:
<script language="JavaScript" type="text/JavaScript">
function imgWin(url,width,height) { 
features= "width=" + width + ",height=" + height; 
newWin = window.open ('', '', features); 
pageCode = "<html><head><style type='text/css'>body {margin:0; padding:0; border:0; font-family: Arial; background-color: #cdc7bf; text-align: center;}a:link {color: #003333;font-size: 10px;} a:visited {color: #003333;font-size: 10px;} a:hover {color: #886600; font-size: 10px;}</style></head>"; 
pageCode += "<body><img src='" + url + "'><br><a href=\"javascript:window.close()\">Close Window</a></body></html>"; 
newWin.document.write(pageCode); 
newWin.document.close(); 
}
</script>
You could also use this to close by clicking the new popup window;
Add this to the body code for the popup
Code:
 onblur="window.close()" onmousedown="window.close()">
then make the link like this;
Code:
<body onblur=\"window.close()\" onmousedown=\"window.close()\"><img src='" + url + "'><br><a href=\"javascript:window.focus();()\"></a>Click anywhere to close this Window</body>
You can test them both here;
Close link

close anywhere window

Cheers!
__________________
Good Luck on your fix

My real hobby..JoyCo
My real Job..(Second Hobby) IAFF Local 1865
Like the sites? My hobby is the one that created them!

Last edited by Sequal7 : 04-Mar-2008 05:35 PM.
twoshoes's Avatar
Member with 41 posts.
 
Join Date: Nov 2004
Experience: Intermediate
04-Mar-2008, 05:43 PM #3
Hey thanks man, and for the fast reply. Your the best! Might meet this deadline yet
Sequal7's Avatar
Computer Specs
Distinguished Member with 2,369 posts.
 
Join Date: Apr 2001
Location: Around the corner!
Experience: Including today?
04-Mar-2008, 05:47 PM #4
You are welcome, good luck on the launch...Now you can charge more as well, saying you had to "outsource because of some bugs in the requested script change"

Cheers!
twoshoes's Avatar
Member with 41 posts.
 
Join Date: Nov 2004
Experience: Intermediate
04-Mar-2008, 07:28 PM #5
Haha yeh why not . One quick thing and this doesnt really matter but when i open the window its goes to the top left of the screen, do you know of a quick way to make it center?
Sequal7's Avatar
Computer Specs
Distinguished Member with 2,369 posts.
 
Join Date: Apr 2001
Location: Around the corner!
Experience: Including today?
05-Mar-2008, 01:55 AM #6
You would have to add the window values x and y, it gets pretty complicated and I don't know how to begin in your example....
something like
Code:
pos,infocus){
if(pos=='random'){
LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=='center'){
LeftPosition=(screen.width)?(screen.width-w)/2:100;
TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!='random')
If you were popping up a html file you could add some javascripts to it and make it appear in the center, but there really isn't a body tag in your file (there is a javascript generated one) and that is where the complications lie.
__________________
Good Luck on your fix

My real hobby..JoyCo
My real Job..(Second Hobby) IAFF Local 1865
Like the sites? My hobby is the one that created them!
twoshoes's Avatar
Member with 41 posts.
 
Join Date: Nov 2004
Experience: Intermediate
05-Mar-2008, 04:06 PM #7
Im with ya, yeh might just leave it out for now till I can learn more java. Thanks again though
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 01:05 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.