/    Sign up×
Community /Pin to ProfileBookmark

close window

Wondering how I can make the new window that pops up with my image close when you click on the image using the following script example…

var imgWin = window.open(“”,’imgWin’,’width=500,height=10,left=25,top=75,toolbar=0,status=0,scrollbars=no’);

with (imgWin.document) {

writeln(‘<body onload=”self.focus();”><img id=”pic” style=”display:none” /></body></html>’);
}

Something like…
imgWin .document.img.onclick = window.close();

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KramyApr 02.2006 — I think you may have answered your open question...
[CODE]var imgWin = window.open("",'imgWin','width=500,height=10,left=25,top=75,toolbar=0,status=0,scrollbars=no');
imgWin.document.write('<html><head><title>This is my Image.</title></head><body onload="self.focus();"><img id="pic" style="display:none" onClick="window.close();" /></body></html>');[/CODE]
You can split the write() up if you want. You could make a function that takes an image's location and Title, and writes those.

function OpenImg(sImgSrc, sImgTitle)
{
var imgWin = window.open("",'imgWin','width=500,height=10,left=25,top=75,toolbar=0,status=0,scrollbars=no');
imgWin.document.write('&lt;html&gt;&lt;head&gt;&lt;title&gt;'+sImgTitle+'&lt;/title&gt;&lt;/head&gt;&lt;body onload="self.focus();"&gt;&lt;img src="'+sImgSrc+'" style="display:none" onClick="window.close();" /&gt;&lt;/body&gt;&lt;/html&gt;');
}
No idea if that code will actually work. ?
Copy linkTweet thisAlerts:
@ranosbauthorApr 02.2006 — Thats just what the doctor ordered...

Thanks ?
×

Success!

Help @ranosb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...