Closed Thread Icon

Topic awaiting preservation: Having difficulties with a script, would appreciate some help Pages that link to <a href="https://ozoneasylum.com/backlink?for=22501" title="Pages that link to Topic awaiting preservation: Having difficulties with a script, would appreciate some help" rel="nofollow" >Topic awaiting preservation: Having difficulties with a script, would appreciate some help\

 
Author Thread
Suho1004
Maniac (V) Mad Librarian

From: Seoul, Korea
Insane since: Apr 2002

posted posted 07-10-2004 03:46

OK, I have (I think) a script that is acting quite erratically, and I can't figure out why. I have had no problems with it until very recently--yesterday, in fact.

The script I'm referring to is the pop up script I use on my site. Some of you may remember this (considering that I pretty much lifted the code/idea from the work of a certain inmate or two). The first thing I need to do, though, is establish what kind of behavior I'm getting, because a friend of mind reported different behavior from what I'm seeing.

OK, enough abstractions. Please take a look at this photo. Click on the photo. Most likely, the larger version of the picture will simply open up in the same window, no pop up. Now take a look at this photo (the next in the series). Again, click. This is where the behavior seems to vary. In my case, this pop up works fine, but my friend reported that this pop up didn't work either. In fact, he tells me that none of the pop ups work in the new gallery, yet all the old galleries work fine. For example, try out this photo. Unless I am going completely insane, this should work.

Here is the relevant code, starting with the JavaScript:

code:
function popUp(image, title, width, height, scroll)
{
win = window.open('','win','width='+width+',height='+height+',scrollbars='+scroll+',resizable=1');
win.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" );
win.document.write("<html>\n<head>\n<title>"+title+"</title>\n");
win.document.write("<style type='text/css'>\n");
win.document.write("body{margin: 0; padding: 0;}\n");
win.document.write("</style>\n");
win.document.write("<head>\n<body>\n");
win.document.write("<img src=\"/"+image+"\" border=0 alt=\""+title+"\">\n");
win.document.write("</body>\n<html>");
win.document.close();
}



Now, here is the html that calls this function for our rogue photo (the one that doesn't want to pop up):

code:
<a href="imagery/everland/photo0b.jpg" onclick="popUp('imagery/everland/photo0b.jpg', 'Hyunjin's mother and father', 700, 525, 0);return false">



And here is the html that calls the function for the example above that works (or should work):

code:
<a href="imagery/experimental/photo0b.jpg" onclick="popUp('imagery/experimental/photo0b.jpg', 'Monument reflection', 525, 700, 1);return false">



Notice the differences in the code. Oh, silly me, there are no differences. The different numbers, of course, are because the first picture is horizontally aligned, while the second picture is vertically aligned. If you'd like to see another horizontally aligned photo that works, try this photo.

First of all, I need to know what sort of behavior you are seeing. Are you seeing what I'm seeing (ie, the first picture in Everland doesn't work but the rest do), what my friend is seeing (ie, none of the pictures in Everland work, but the other galleries do), or something else (ie, that either all the pictures work, or none of the pictures work, or some other wacky combination different from the above)? I am confused because I was under the impression that a script should work the same if you plug in the proper variables, but for some reason this script is acting differently. The logical answer would be that I screwed up, not the script, and to be honest I'm sincerely hoping that I did something really stupid that I'm just not seeing. The problem is that everything is generated server-side by the same PHP script, so all I have to do is drop the photos in the proper folder and everything else is done for me--ie, there's very little room for me to actually screw up anything. The only thing I could really screw up is the file names of the photos (for example, I accidently give a photo the file name "photo12v.jpg" instead of "photo12b.jpg"), but that wouldn't change the popup behavior--I would just get a pop up with a red X.

Yeah, so, anyway, I'm pretty stumped. Fortunately, the way I have things set up, you can still see the larger versions even if the JS fails, but it's just bugging the living daylights out of me because it doesn't seem to make sense. I'm desperately praying that someone will reply with "Suho, you moron, you did this wrong," and then everything will work. The only other real option I see is that maybe there was something wrong with the original script that for some reason didn't rear its head until now. I'm out of answers.

[Edit: I suppose I should mention that none of the pop ups will work if you have JS turned off or if you have your Internet Security level set to High in IE (which basically means that you have JS turned off). I know that should be obvious, but I take nothing for granted anymore.]

___________________________
Suho: www.liminality.org | Cell 270 | Sig Rotator | the Fellowship of Sup | "Hooray for linguistic idiots and yak milk!"

(Edited by Suho1004 on 07-10-2004 03:48)

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 07-10-2004 04:40

Safari and Mac IE:
first link opened in the original window; link 2 and 3 both spawned pop up windows.
For what it's worth.

Suho1004
Maniac (V) Mad Librarian

From: Seoul, Korea
Insane since: Apr 2002

posted posted 07-10-2004 05:32

Cheers. That's the behavior I'm seeing on PC IE. In a way it makes me feel better, because it shows some consistency in the behavior, but in a way it just confuses me even more...

Strangely enough, in Firefox I get nothing on the first link (no reaction at all, which is odd), but the other links work fine. I'm just totally confused now.

___________________________
Suho: www.liminality.org | Cell 270 | Sig Rotator | the Fellowship of Sup | "Hooray for linguistic idiots and yak milk!"

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-10-2004 06:05

'Hyunjin's mother and father'

Gotta escape the apostrophe.

'Hyunjin\'s mother and father'

[edit: by the way, weren't you getting any javascript errors? if so, they may have helped you find the problem.]



(Edited by Slime on 07-10-2004 06:06)

Suho1004
Maniac (V) Mad Librarian

From: Seoul, Korea
Insane since: Apr 2002

posted posted 07-10-2004 07:05

Son of a bagel. I can't believe it! The amazing thing is that I've run into this very same problem before... I don't know what I was thinking. Must be having a stupid day on the JS front. Thanks, Slime.

[Edit: Fixed.

And, by the way, there is another solution, other than escaping with the backslash. I usually replace all of my quotation marks, etc., with HTML entities, but sometimes a few slip through the cracks. Most of the time it's not fatal, but the ones in the titles do break the JS. I still can't believe I didn't think of that, especially since I managed to figure this out on my own in the past.

Oh, Slime: you forgot the "Suho you moron" part ]

___________________________
Suho: www.liminality.org | Cell 270 | Sig Rotator | the Fellowship of Sup | "Hooray for linguistic idiots and yak milk!"

(Edited by Suho1004 on 07-10-2004 07:11)

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 07-10-2004 09:10

Suho1004: As a side note, I don't know how your backoffice works, but I suggest you to turn you function calls from :

code:
<a href="imagery/everland/photo0b.jpg" onclick="popUp('imagery/everland/photo0b.jpg', 'Hyunjin's mother and father', 700, 525, 0);return false">

to this

code:
<a href="imagery/everland/photo0b.jpg" onclick="return !popUp(this, 'Hyunjin's mother and father', 700, 525, 0)">

And I also thing that passing the width, height and scrolling ability of the window is useless. Since JavaScript must be activated for this to work, then you could retrieve the size of the image and that of the screen onload of the popup and resize the window.

[edit]In fact, you could also get rid of the title argument as it should be present in the title attibute of the A tag, or in the alt the nested IMG tag. [/edit]

Cheers,



(Edited by poi on 07-10-2004 09:13)

Suho1004
Maniac (V) Mad Librarian

From: Seoul, Korea
Insane since: Apr 2002

posted posted 07-10-2004 09:52

Thanks, poi. I'll take a look into streamlining it.

re: the title--It is in the alt of the nested image tag, but if I don't pass the title along how will the popup window know to display it? I'm a bit confused on that.

___________________________
Suho: www.liminality.org | Cell 270 | Sig Rotator | the Fellowship of Sup | "Hooray for linguistic idiots and yak milk!"

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 07-10-2004 11:50
quote:
Suho1004 said:

if I don't pass the title along how will the popup window know to display it?

it will because you'll pick the title -- sorry, the alt of the thumbnail image -- in the popUp( ) function and insert it in the popup window.

Suho1004
Maniac (V) Mad Librarian

From: Seoul, Korea
Insane since: Apr 2002

posted posted 07-10-2004 12:04

Ah... I see. I've actually forgotten most of the JavaScript that I used to know, which is why I originally did it the way I did. I'm not sure when I'll get the chance to rework this, but when I do, I will most likely require assistance.



___________________________
Suho: www.liminality.org | Cell 270 | Sig Rotator | the Fellowship of Sup | "Hooray for linguistic idiots and yak milk!"

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 07-10-2004 12:22

Actually by passing only this to the popUp( ) function, it's tricky to get the script working in NN4. The only way I thought of would have complexified (?) the function a bit and required to put a substring of the href in the name attribute of the thumbnail image.

[edit] it seems that the alt attribute of an IMG is not accessible in NN4. [/edit]



(Edited by poi on 07-10-2004 12:35)

« BackwardsOnwards »

Show Forum Drop Down Menu