?
Solved

Problem With The Pop-Up Window

Posted on 2003-03-21
7
Medium Priority
?
544 Views
Last Modified: 2013-11-28
Hello guys!

Here it is the pop-up window code that I want to use. It does exactly what I need.
So the images show in a pop-up as I need them to, but if the webpage is long and the link that you click on to open the image is somewhere down the page, when the pop-up shows up the webpage goes back to the top. That is very annoying as you might actually need to stay on the same spot on the page, so you don't want to have to scroll back to the place you were before clicking on each of those image links.

Could you guys PLEASE tell me what I have to do in order to keep the same spot on the page after you click on the image link, and it pops-up?!

Here it's the code:
===================

<!---Head--->
<script language="JavaScript">
<!--
function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {

if (bgcolor=="") {
bgcolor="#FFFFFF";
}
var adj=10, lift;
var w = screen.width;
var h = screen.height;
var byFactor=1;

if(w<740){
lift=0.90;
}
if(w>=740 & w<835){
lift=0.91;
}
if(w>=835){
lift=0.93;
}
if (imageWidth>w){
byFactor = w / imageWidth;
imageWidth = w;
imageHeight = imageHeight * byFactor;
}
if (imageHeight>h-adj){
byFactor = h / imageHeight;
imageWidth = (imageWidth * byFactor);
imageHeight = h;
}

var scrWidth = w-adj;
var scrHeight = (h*lift)-adj;

if (imageHeight>scrHeight){
imageHeight=imageHeight*lift;
imageWidth=imageWidth*lift;
}

var posLeft=0;
var posTop=0;

if (hugger == "hug image"){
if (hugMargin == ""){
hugMargin = 0;
}
var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
if (scrHeightTemp < scrHeight) {
scrHeight = scrHeightTemp;
}
var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
if (scrWidthTemp < scrWidth) {
scrWidth = scrWidthTemp;
}

if (scrHeight<100){scrHeight=100;}
if (scrWidth<100){scrWidth=100;}

posTop = ((h-(scrHeight/lift)-adj)/2);
posLeft = ((w-(scrWidth)-adj)/2);
}

if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
imageHeight=imageHeight-adj;
imageWidth=imageWidth-adj;
}

var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1){
var args= new Array();
args[0]='parent';
args[1]=imageName;
var i ; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
} else {
newWindow = window.open("","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
newWindow.document.open();
newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');
newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="Click screen to close" >');
newWindow.document.write('</td></tr></table></body></html>');
newWindow.document.close();
newWindow.focus();
}
}
//-->
</script>
<!---Body--->
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>

<a href="#" onClick="JustSoPicWindow('myimage.jpg','640','480','RUNECENTRAL.TK • Click window to close','#FFFFFF','hug image','0');return document.MM_returnValue">click to view image</a>

=====================
This is all I need to fix to get my webpage up and running soon.

Thank You Very Much!!

Diablomax
0
Comment
Question by:diablomax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 8184909
This is the JSP area. You should have asked this in  the JavaScript area. But here is my idea.
You have
><a href="#" onClick="JustSoPicWindow(.....
I would add a name.
><a href="#popup" name="popup" onClick="JustSoPicWindow
See, if that works.
0
 

Author Comment

by:diablomax
ID: 8185316
Thanx RRZ!

I didn't realize that this is JSP, you are right I'll post my question there.
Thank you for the suggestion I'll try it.
0
 

Author Comment

by:diablomax
ID: 8185737
Hello RRZ!

Your idea of adding a name works!!

THANK YOU VERY VERY MUCH!!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:diablomax
ID: 8185770
Actually it doesn't really work :-(

No matter where you are at the top of the page or at the bottom, always takes you at a certain point on the page... I don't know why it chooses that point, it's a little bit down, like scrolling almost one inch down the page.
So no matter where you are when you click on the link for the image to pop up, it takes you to the point where you would be if you scroll down about one inch.
0
 
LVL 28

Expert Comment

by:rrz
ID: 8186448
You can create an anchor anywhere on your page. Use
<a name="anchorname">  
then in your link use  
><a href="#anchorname"  onClick="JustSoPicWindow(.....  
When the link is clicked, the particular part that the anchor references, should be displayed at the top of the browser window.
0
 
LVL 2

Accepted Solution

by:
_marko_ earned 200 total points
ID: 8188039
<a href="javascript:void(0);" onClick="JustSoPicWindow(


Regards,

Marko
0
 

Author Comment

by:diablomax
ID: 8189252
Hello RRZ!!
Hello Marco!!

Marco! your solution works!! I tested couple of times just to make sure and it works, exactly the way I wanted.

THANK YOU VERY MUCH MARCO!!! That is what I'm using now.

RRZ! your solution works too, the one that you offered me first time, BUT it worked when I tested it stand alone on a test page. In combination with the other scripts that I have on my webpage didn't work, so looks like was conflicting with something there on the actuall webpage that I'm working on.

ANYWAY THANK YOU VERY MUCH RRZ!!

Guys! Thank You a BUNCH!! You were VERY HELPFUL!! :-)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Starting your own business is always a daunting process, and for most people it is brand new experience. Avoid the common pitfalls by following these tips to start on the road to success.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question