trouble with Javascript Pop-up

D

djdefpoints

I grabbed and modified the following script from the publishermvps site:

<a href="BLOCKED
SCRIPTwindowname_window=window.open'testpage.htm','windowname_window','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=428', height=480');windowname_window.focus()">More...</a>

I inserted this code fragment into my document, published to web, and
likewise, published-to-web the document called testpage. Both the main
webpage document (called index-test.htm) and testpage.htm reside in the same
folder on our network server. I assumed I could test this fragment out
before actually putting the documents on our website, but the link doesn't
work. I get the hyperlink on the page (More...) but when I click on it,
nothing happens. I'm a bit confused.

Side question: will pop-up blockers be a problem for this code snippet? (I
actually have trouble on this site with that - this posting window gets
blocked.)

Thanks in advance for your help.
 
D

DavidF

I have many times tried different scripts, only to find they didn't work for
me. I am sure that the problem was usually my ignorance of coding, and
trying to modify code and messing it up. New window script was one of those.
I must of tried 6 or 7 before I managed to make one work in the way I wanted
it to.

While someone might be able to figure out what you did wrong, you might go
back to the site where you found the code and try to carefully troubleshoot
your code, or, if you get frustrated then just find a different approach,
like I did. There are lots of free code snippets available, some easier to
understand and make work than others. I would suggest that you Google for
"new window JavaScript", and check out some alternatives. I just got
4,770,000 results on those words alone...

And by the way, I did waste 15 or 20 minutes trying to figure out what your
problem was, before I got frustrated and decided on this response...life is
too short...sorry ;-)

DavidF
 
D

djdefpoints

Thanks, David, for givin' it a go. I guess I'm off to Dynamic Drive for a
snippet.
 
D

DavidF

Hey, no sig...I just reread your original post. If I read it correctly, then
did you ever actually upload all the files to your webhost? The script you
used might require that...

Thanks for posting back. Good luck.

DavidF
 
D

djdefpoints

It works! I uploaded a script from Dynamic Drive (man, what a site!) that
solved my problem. Apparently, you need 2 scripts. This is the link, for
those interested:http://dynamicdrive.com/dynamicindex8/popwin.htm

I didn't think it would work, since it calls for a header, which I know
Publisher gets cranky about. But cutting and pasting both scripts in the
document seems to work, even calling on the testpage I set up from within our
browser. I'll have to be careful when I actually go live to the web, of
course. Thanks, David, for your replies.
 
D

DavidF

That is good news! You are welcome and thanks for posting the link...

From my personal experience, I too have found that code snippets that say I
have to put part of the code in the head section, will often work if I just
insert them into the body of a Publisher document.

DavidF
 
D

djdefpoints

ARGH...happiness short-lived...now the link text seems to wander all over the
page, depending on the user's monitor settings. From a search of this site
and some tests, it seems that this is partly due to layering the fragment
over a text-box, but even then, when I move it to the open, the link text is
placed far down the page, as if making room for items above. Kinda stumped
how to fix.
 
D

DavidF

I have never been able to layer a fragment box over any other design
element...surprised to hear it worked at all. The page generated should be
fixed as far as width. Are you trying some sort of centering code? I have
seen text boxes lengthen when the text size is changed in the browser, but
otherwise the user's monitor shouldn't make a difference. Perhaps if you
explained that in more detail.

You might play with the size of the fragment box...and you aren't using a
master page are you?

DavidF
 
D

djdefpoints

Let me clarify:
What works: the text link itself, the pop-up window generated
What's wrong: the location of the text link on different monitors (on my
coworker's monitor, for instance, it appears half-way down the page from
where it does on mine.)

Here's the text link code, which appears twice on the main page (and
"wanders" in different browsers):
<a href="testpage2.htm"
onclick="NewWindow(this.href,'mywin','528','600','no','center');return false"
onfocus="this.blur()"><span
style='font-size:7.0pt;letter-spacing:1.0pt;language:EN'>more...</span></a>

Here's the script for the pop-up:
<script language="javascript" type="text/javascript">
<!--
/****************************************************
Author: Eric King
Url: http://redrival.com/eak/index.shtml
This script is free to use as long as this info is left in
Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos)
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") ||
pos==null){LeftPosition=0;TopPosition=20
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// -->
</script>

There is a centering code, but in the script (for the new pop-up window),
not the text link, yes?

What I've done:
-placed text link in different locations, the only one that doesn't shift on
different monitors is at the very top corner of the page
-placed the text link both layered over another object and in free space -
no effect
-used a script that linked an image instead - same problem, except now its a
wandering image.

And no, no master page...learned that lesson my first time here!
 
D

DavidF

I was talking about some script to center your page on the monitor, vs. it
being left justified as by default...not your new window.

Are you using a laptop, and your friend a desktop with different
resolutions? A number of people have complained about the wide aspect
laptops, and viewing Publisher sites. If you are using a desktop to produce
the site, can you view it with another desktop? Is the resolution the same
on the two computers that you are using?

I guess the next step is to post the URL of your test page. Tell me where
the text link is supposed to be located on your page.

DavidF
 
D

djdefpoints

Ah, no the page itself is not centered. I kept it to a small width, to avoid
issues with visibility on other systems. (ironically) The issue seems to
have been that I had my monitor set to 120 dpi, everyone else in the office
had it at 96. This actually affected how the program generated the HTML.
Doesn't solve the overall issue: I'm sure the website will look odd on a
different set-up, but, as far as I can tell, this is unavoidable to a degree
with Pub2003, and WSYWIG progs in general.

Don't yet have a test-page URL. The page is strictly in-house at this
point, since it really doesn't have content yet. I'll post back when I've
uploaded to the host. Thanks, David.
 
D

DavidF

Ok, it does sound like the same issue of resolution, and I don't have a
magic solution.

When you use the compress images function in Pub 2003, pictures are
"resampled" at 96 dpi, and I think it could be said that the code is setup
in general for 96 dpi viewing. Of course that means that if you produce it
at 120 dpi, when the HTML is viewed by a monitor at 96, everything will
appear differently. Though it would probably be a pain in the rear gear,
have you considered resetting your machine at 96 to produce the code? If you
did this with your test files, how do they look after you reset your
machine, and how do they then look on the office machines?

For what its worth, I used to have this problem when I switched back and
forth between my laptop and desktop. What I found was that I could work on
the Publisher file on my laptop, but copied it over to my desktop to produce
the code before I posted it. In fact, I posed the question to David Bartosik
the resident MVP and true expert, and he lost a small bet when I sent him
the code from the two machines, and they did end up producing different
pages. Does anyone else in the office use Pub 2003, and would they let you
copy your Pub file to their machine long enough to produce the HTML code, to
see if that resolves the issue?

I read through some old posts about this issue, and it was said that
professional web designers can use various techniques to mitigate this
problem, but of course as you point out this is beyond the scope of
Publisher. I also read somewhere that if you set your monitor to its default
resolution, that might help??? However, there was also one poster who
devised a workaround. Now I am neither a programmer or a professional web
builder, and know little about code, but perhaps you can understand what he
was saying. Here is the link:
http://groups.google.com/group/micr...974?lnk=gst&q=96+dpi&rnum=29#dbb742a2cd633974

I would be interested in what solution you come up with, (he optimistically
said ;-) And by the way, how large is your Publisher file? And how large is
your HTML output? I am not sure I can reproduce your error, but it might be
interesting to forward your files to the MS Publisher team, to get their
input.

DavidF
 
D

djdefpoints

Thanks for your ongoing interest in this. Well, the "magic solution" appears
to be simply resetting my monitor to 96dpi! I frankly don't even know why it
was set to 120 - doesn't make an appreciable difference. I'm glad its that
simple. I tried it on our company lap-top, and it works fine. Will it work
on a linux box in Saipei running Firefox? Probably not, but I think our
set-up is typical enough for our purposes - we're not using forms or selling
anything, it's just pretty pictures. The link to the C-program is probably
beyond what we can achieve here. (That has to be compiled with a C
compliler, doesn't it?)

We're pretty close to going live with the site. I'll post back then, and
you can take a look at/forward the source (and admire our fancy site, built
with Publisher 2003!)

Thanks, David.
 
D

DavidF

That's good news. Thanks for posting back.

Now don't forget to run graphics compression before you post the site,
especially since you will have lots of images. Also go to Tools > Options >
Web tab, and untick the "allow PNG...: and "VML..." settings. Do the three
things and your site will load more quickly. And in case you are wondering
about the graphics compression:
http://office.microsoft.com/en-us/assistance/HA011266301033.aspx

I'll look forward to seeing your site...

And C-program...beats me. Heck, if I understood that, I probably wouldn't
still be using Publisher ;-)

DavidF
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top