/    Sign up×
Community /Pin to ProfileBookmark

modify JS so not to open in same window

hello ,
i am using the below javascript for a photo gallery i have setup.
each photo has a different image size so i use variables in the JS to create popup windows based on the size of the photos.

problem is that if the popup is not closed, all photos are opening in it and keeping the size of the 1st one opened
ie,
clicked on image 1, popup of 400×400 opens, all looks nice
click on image 2, the image loads in the prvs popup and stays 400×400 even if i would have set it 200×200

so how can i fix that? ?
i think easiest is to have a new window for every click, but how ?

<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
function view(u, l, t, w, h) {
var windowprops = “URL=” + u + “,location=no,scrollbars=no,menubars=no,toolbars=no,resizable=no” + “,left=” + l + “,top=” + t + “,width=” + w + “,height=” + h;

popup = window.open(u,”MenuPopup”,windowprops);
}
// End –>
</script>

and link used:
javascript:view(‘/pictures/viewer.php?link=2004/P1.JPG&w=586&h=624’, 50, 160, 586, 624)

using script on site [url]www.lulpaintings.com[/url] go to gallery->2004 and try the 1st 2 pictures to c an example of the problem

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@SpectreReturnsApr 25.2005 — <i>
</i> function showPhoto (file, width, height) {
if ($openPhoto) {
$openPhoto.close();
}
width += 12;
height += 12;
$openPhoto = window.open('view.php?image='+file,'rmlphoto','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height);
}

Use something like that. Set a variable to the opened window, then the next time you open it check if it isn't null, and if so close it.
×

Success!

Help @karxix 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...