...

View Full Version : can't figure out this pop-up



ubtheboss
06-18-2002, 11:31 PM
Howdy,

I have been struggling with a couple of scripts I found at javascriptkit.

I simply want a pop-up window but I would like a button instead of a text link that activates the pop-up (like the one they have in their pop-up tutorial)


<form>
<input type="button" value="Click here to see">
onclick="window.open('page2.htm',
'win1','width=200,height=200')"
</form>

But I am also having trouble with the pop-up script that was generated for me with their pop-up wizard.


<script>

//Popup Window Script
//By JavaScript Kit (http://javascriptkit.com)
//JavaScript tutorials and over 400+ free scripts

function openpopup(){
var popurl="venice_beach_sunsetpoll.htm"
winpops=window.open(venice_beach_sunsetpoll.htm,"","width=400,height=338,scrollbars,resizable,")
}

</script>

<a href="javascript:openpopup()"><font color="#FFFFFF">Please cast your vote on this photo CLICK HERE</font></a>


When I preview it in my browser it says "venice_beach_sunsetpoll.htm is undefined"

Being a cut and paste kinda programmer I don't know what this means.

Since I am conducting a poll in this pop-up window I want my visitors to view the results in the same pop-up window but is there a way to make the dimensions of the result page different?

If someone could marry the two scripts above and show me what I am doing wrong overall I would really appreciate it.



Thank You!

JohnKrutsch
06-19-2002, 01:19 AM
Try something like this:


<script>

//Popup Window Script
//By JavaScript Kit (http://javascriptkit.com)
//JavaScript tutorials and over 400+ free scripts

function openpopup(){
var popurl="venice_beach_sunsetpoll.htm"
winpops=window.open(popurl,"","width=400,height=338,scrollbars,resizable,")
}

</script>
<form>
<input type="button" value="Click here to see" onclick="openpopup()" >
</form>


You had venice_beach_sunsetpoll.htm written out instead of calling the variable that represented it.

ubtheboss
06-19-2002, 02:04 AM
Thank you John.

Another question:

- I want to put two of these scripts on one page. I tried changing the variable 'popurl' of one of them to 'popurl2' but that didn't work.

??

JohnKrutsch
06-19-2002, 04:20 AM
Try something like this:

<script>

//Popup Window Script
//By JavaScript Kit (http://javascriptkit.com)
//JavaScript tutorials and over 400+ free scripts

function openpopup(popurl){
winpops=window.open(popurl,"","width=400,height=338,scrollbars,resizable,")
}

</script>
<form>
<input type="button" value="Click here to see" onclick="openpopup('venice_beach_sunsetpoll.htm')" >
<input type="button" value="Click here to see" onclick="openpopup('a_different_page.htm')" >
</form>

this way you pass in the page as a variable

ubtheboss
06-20-2002, 08:13 PM
Thanks again John.

That works but the problem is that I need different sized windows for each function/button (one calls up a poll and the other a guestbook sign in form)

Can you help me with that?

Cheers!

Phil

JohnKrutsch
06-20-2002, 08:57 PM
Sure just pass those in too:

<script>

//Popup Window Script
//By JavaScript Kit (http://javascriptkit.com)
//JavaScript tutorials and over 400+ free scripts

function openpopup(popurl,settings){
winpops=window.open(popurl,"",settings)
}

</script>
<form>
<input type="button" value="Click here to see" onclick="openpopup('venice_beach_sunsetpoll.htm','width=400,height=338,scrollbars,resizable,')" >
<input type="button" value="Click here to see" onclick="openpopup('a_different_page.htm','width=200,height=200')" >
</form>

ubtheboss
06-20-2002, 11:41 PM
That works! Once again, thank you.

One small problem though. For some reason my pop-up windows are starting to pop-up with half of the window half off the screen to the right. I have to click on the top bar of the window and drag it to the left so the whole window is visible on screen.

What is causing this and is there a cure?

Cheers!

Phil

whammy
06-21-2002, 12:00 AM
Try this popup generator:

http://www.a1ien51.8k.com/scripts/popupwingenV2.htm

It rocks...

You can use the code it generates (including centering), and modify it to pass the variables you want into your function...

Like:

<script language="javascript" type="text/javascript">
<!--
function PopUp(PopUpUrl,thewidth,theheight){
var ScreenWidth=window.screen.width;
var ScreenHeight=window.screen.height;
var movefromedge=0;
placementx=(ScreenWidth/thewidth)-((thewidth)/2);
placementy=(ScreenHeight/theheight)-((theheight+50)/2);
WinPop=window.open(PopUpUrl,"","width="+thewidth+",height="+theheight+",toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",");
}
// -->
</script>

<a href="javascript:PopUp('http://www.barbie.com',400,300)">Barbie</a><br />
<a href="javascript:PopUp('http://www.yahoo.com',800,600)">Yahoo!</a><br />

ubtheboss
06-21-2002, 12:22 AM
Thank you whammy. That is a great tool for creating pop-ups.

In my particular case however I really like John's way of creating what I needed with just one set of code and passing on the popurl and the settings.

This may be possible with the tool you showed me but I am not a programmer so I wouldn't know how to alter it.

So, John I appeal to you again, or someone, who can show me what extra code to add and where to add it in order to stop my two pop-ups from appearing half off the screen.

Thanks all.

Cheers!

Phil

whammy
06-21-2002, 12:23 AM
Actually I just did... check out the part where it centers the popup on the screen. Have you copied and pasted that and checked it out? ;)

ubtheboss
06-21-2002, 12:35 AM
Yes, I checked out that pop-up generator and clicked the 'preview' button and it was great. If I just wanted one pop-up window then that would have solved everything but if you read through the posts in this thread you'll see that I am trying to open two different pages in two different pop-ups with different window sizes. So far John has helped me get there but now the windows are appearing half off the screen. That's the problem.

If you can show me where I can do all of this with the pop-up generator code then sure I'll use that.

By the way, surfing around that pop-up window generator site I was assaulted by pop-ups myself PLUS I got a VIRUS warning from my virus protection software. I am now having to sweep my hard drive for others.

The pop-ups were annoying but understandable- the site is free.

The virus.........???

whammy
06-21-2002, 12:37 AM
Did you try the modified code that I posted above? It opens two separate popups at two different sizes... and I didn't modify it for my own health... :D

ubtheboss
06-21-2002, 12:42 AM
Ok. I see what you did. Sorry. Like I said I am not a programmer and barely figure out what all this stuff means.

Now to make myself more of a pain, what do I do if I want to use buttons instead of text links for the two pop-ups?

Cheers!

whammy
06-21-2002, 12:43 AM
<input type="button" value="My Button Name!!" onClick="PopUp(whatever)" />

:D

ubtheboss
06-21-2002, 12:52 AM
Ok. Well I tried YOUR modified code. It won't work. Just to show you that I am using the same code as listed above I am going to cut and paste it below straight out of Front Page

<script language="javascript" type="text/javascript">
<!--
function PopUp(PopUpUrl,thewidth,theheight){
var ScreenWidth=window.screen.width;
var ScreenHeight=window.screen.height;
var movefromedge=0;
placementx=(ScreenWidth/thewidth)-((thewidth)/2);
placementy=(ScreenHeight/theheight)-((theheight+50)/2);
WinPop=window.open(PopUpUrl,"","width="+thewidth+",height="+theheight+" ,toolbar=0,location=0,directories=0,status=0,scrol
lbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",");
}
// -->
</script>

<a href="java script:PopUp('http:/www.barbie.com',400,300)">Barbie</a><br />
<a href="java script:PopUp('http:/www.yahoo.com',800,600)">Yahoo!</a><br />





No pop-ups appear at all. Instead each click goes to a non-existant page in the full browser page.

Now, obviously www.yahoo.com does exist so somewhere there lies a problem. I have no idea. I'm not a programmer.

whammy
06-21-2002, 12:53 AM
the code when pasted here inserts line breaks... try putting all the stuff that looks like it should be on one line on one line... then it will work...

ubtheboss
06-21-2002, 01:02 AM
I'm sorry. I just don't know enough to know what should be on one line and what is fine.

When I copied the script that you gave me the first time I pasted it into a txt document then copied and pasted it into MSFP.

The only signs of line break that this simple unschooled in java fool can see is the </b> that appears twice but removing them changed nothing.

:(

whammy
06-21-2002, 01:05 AM
Umm... ok... looky here:

<script language="javascript" type="text/javascript">
<!--
function PopUp(PopUpUrl,thewidth,theheight){
var ScreenWidth=window.screen.width;
var ScreenHeight=window.screen.height;
var movefromedge=0;
placementx=(ScreenWidth/thewidth)-((thewidth)/2);
placementy=(ScreenHeight/theheight)-((theheight+50)/2);
WinPop=window.open(PopUpUrl,"","width="+thewidth+",height="+theheight+" ,toolbar=0,location=0,directories=0,status=0,scrolREMOVE LINE BREAK HERElbars=0,menubar=0,resizable=0,left="+placementx+",top="+placeREMOVE LINE BREAK HEREmenty+",screenX="+placementx+",screenY="+placementy+",");
}
// -->
</script>

<a href="java script:PopUp('http://www.barbie.com',400,300)">Barbie</a><br />
<a href="java script:PopUp('http://www.yahoo.com',800,600)">Yahoo!</a><br />

I don't know if I caught them all... but that should give you an idea :confused:

ubtheboss
06-21-2002, 01:23 AM
Ok. Some progress. I got the pop-ups to pop up BUT......

I still have the same problem. The pop-up windows are appearing half off the screen on the right.

I went back to that pop-up code generating site you gave me and created a code and previewed it there just to check and see where it would put the preview pop-up on my screen. I selected 'center' and it put it dead center.

:confused:

whammy
06-21-2002, 01:25 AM
Unfortunately I don't have any other advice to offer... I'd just play around with it if I were you until you get it to work... the first code I posted works fine for me.

ubtheboss
06-21-2002, 01:27 AM
Thank you whammy for your time. I'm going to post a new thread with my question and see if anyone else can help me with John's code.

:thumbsup:

whammy
06-21-2002, 01:40 AM
<script language="javascript" type="text/javascript">
<!--
function PopUp(PopUpUrl,thewidth,theheight){
var ScreenWidth=window.screen.width;
var ScreenHeight=window.screen.height;
var movefromedge=0;
placementx=(ScreenWidth/thewidth)-((thewidth)/2);
placementy=(ScreenHeight/theheight)-((theheight+50)/2);
WinPop=window.open(PopUpUrl,"","width="+thewidth+",height="+theheight+" ,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy);
}
// -->
</script>

<a href="javascript:PopUp('http://www.barbie.com',400,300)">Barbie</a><br />
<a href="javascript:PopUp('http://www.yahoo.com',800,600)">Yahoo!</a><br />

ubtheboss
06-21-2002, 01:44 AM
i did that

whammy
06-21-2002, 01:47 AM
Do it again... It looks like a comma got in there somehow, or something.... anyway, there may have also been some kind of formatting problem that the forum code itself introduced that may have been problematic?

I'm not sure where that extra comma came from, but it seemed to work before I posted it in here... must be one of those vBulletin forum bugs or a bug in a1iens popup generator. ?

Anyway, I just tested the code above (by the way I have modified the last post with script and double-checked it, and it works great)

Just get rid of the ONE line break; it DOES work... I just tested it and it opened barbie and Yahoo! just fine!

ubtheboss
06-21-2002, 02:08 AM
i used your modified code above.

everytime i try and save my html page once i've pasted your code in, it changes the last two lines of your code to:

<a href="java%20script:PopUp('http:/www.barbie.com',400,300)">Barbie</a><br />
<a href="java%20script:PopUp('http:/www.yahoo.com',800,600)">Yahoo!</a><br />


For some inexplicable reason it REMOVES one of the forward slashes in http:// for both urls

I have cut and pasted your code from here to Notepad to MSFP 10 TIMES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Still it does the same thing.

What the heck is going on?!
:mad:

JohnKrutsch
06-21-2002, 03:02 AM
This is basically the same thing whammy is doing:

<script>
//Popup Window Script
//By JavaScript Kit (<http://javascriptkit.com>)
//JavaScript tutorials and over 400+ free scripts

function openpopup(popurl,w,h,settings){
t=screen.height/2-h/2;
l=screen.width/2-w/2;
settings+="width="+w+",height="+h+",top="+t+",left="+l+",screenX="+l+",screenY="+t ;
winpops=window.open(popurl,"",settings)
}

</script>
<form>
<input type="button" value="Click here to see" onclick="openpopup('venice_beach_sunsetpoll. htm',400,338,'scrollbars,resizable,')" />
<input type="button" value="Click here to see" onclick="openpopup('a_different_page.htm',200,200,'')" />
</form>

Try doing this in notepad. Front Page is notorius for messing with your code.

ubtheboss
06-21-2002, 03:28 AM
HUUZZZZZAAAAAAA!!!!!

The problem has been solved. Thank you John. You are the bomb!

There was just a small correction I think I figured out that made it work perfectly

- where you had ('a_different_page.htm',200,200,'')" />

I think that second to last " should be something else but I wasn't sure. It didn't work as is so it had to be something.

So I just mimcked what you had done with the previous one:

('venice_beach_sunsetpoll.htm',225,450,'scrollbars,resizable,')" />

and I replaced that " with

'scrollbars,resizable,')"

Not all of that was necessary I imagine but it WORKED

and the darn windows are CENTERED

I hope maybe someone else benefits from all of this then maybe it was worth all the hours I spent trying to figure this out. Hours I will wish I had back on my death bed.


:D

JohnKrutsch
06-21-2002, 03:31 AM
That was a set of single quotes opened and closed not a single double quote. You can still define all of the other setting you like for each indivdual call to the function.

A1ien51
06-21-2002, 06:34 AM
Hey next time whammy...attach the code if you think you are having trouble!!!

Put it in a text file!!! lol


:thumbsup:

whammy
06-22-2002, 01:16 AM
Geez... no kidding. The first thing I did worked fine... *sigh*

newmate
06-22-2002, 02:05 AM
Hi, I was trying to help a member with a post @
ScriptConfusion (http://codingforums.com/showthread.php?s=&threadid=392) it did start out with a bit of a lack of defination of what the poster wanted/needed. At this point I do think from the first half of this thread that youall(southern) could do the trick for him/her better than I. the jist of it at this point is member is using a popup script coded for URL scr and wanting to use a button option to invoke a flash intro at onclick. So it follows that changing URL to website scr and also IMHO should also include the check for plugin/version_plugin yes play or false=send to get plugin, then play.This at this is over my head and better served by the obviously learned thread responders here.
var thanksrc = "members.now"

Beck
06-22-2002, 11:18 AM
<a href="java script:PopUp('http:/www.barbie.com',400,300)">Barbie</a><br />
<a href="java script:PopUp('http:/www.yahoo.com',800,600)">Yahoo!</a><br />


You have this code written on your copy/pasting above. Your websites are
http:/www.yahoo.com
when they should be
http://www.yahoo.com
with two backslashes after the http:
That might be why you're getting a blank page.
If it doesn't work, post again :)


Beck

janda1geroge
04-27-2009, 05:43 AM
For making your skin an ever youthful beauty. Using the anti aging wrinkle cream is the best way out.
for more infomation piz visit :- http://ezinearticles.com/?Best-Anti-Aging-Skin-Care-Product-According-to-Oprah-and-Dr-Oz&id=2262934



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum