Forum Moderators: open

Message Too Old, No Replies

Help : Get 2 popups to work on same page

Need information...

         

Texas

3:51 pm on Apr 24, 2002 (gmt 0)

10+ Year Member



Hello,

I know many will find this a rather easy problem to solve...and I hope so 'cause I'm stumped.

I am using two popups on the same page. One is called by clicking a link, the other is called by a once-per-browser-session cookie.

How can I get both of them to work properly on the same page?

Here is the code for the clickable link:

<script>

//Popup Window Script
//By Website Abstraction (http://wsabstract.com)
//JavaScript tutorials and over 400+ free scripts

function openpopup(){
var popurl="feedback.html"
winpops=window.open(popurl,"","width=415,height=400,scrollbars,")
}

</script>

Here is the code for the cookie-based popup:

<script>

function openpopup(){
var popurl="http://domain.com/inkpop.html"
winpops=window.open(popurl,"","width=260,height=200,")
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function loadornot(){
if (get_cookie('poppedup')==''){
openpopup()
document.cookie="poppedup=yes"
}
}

loadornot()
</script>

Anyone's experienced advice much appreciated.

The url: <snip>

Texas

(edited by: Xoc at 5:17 pm (utc) on April 24, 2002)

korkus2000

5:49 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What exactly is the problem?

One thing that you should do is name your windows when you create them.

Texas

6:07 pm on Apr 24, 2002 (gmt 0)

10+ Year Member



I tried to post the site's url so you could see first hand, but apparently a forum moderator snipped it.

The problem is that I have two popups on one page and only one will work correctly (the once per browser session one). The other popup is called by clicking the feedback link.

I operate several other websites using multiple popups on a page with no problem. I just name them...

function openpopup1(){
function openpopup2(){
function openpopup3(){ ...etc.

...and they work fine. However, with today's popup problem combo of using the cookie based auto-popup on the same page with the other link-accessed popup, only one will work (the cookie based). The feedback popup link now opens the cookie based inkpop.html

Any ideas for a solution...before I commit suicide?

Texas

korkus2000

6:10 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



did you try adding a name to the windows when you create them?

txbakers

6:13 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hold off on the suicide - it's only electrons and scratches on a page somewhere. No big deal.

You can put URLs in your profile, which people can look at, then go visit your site.

I haven't looked at your code yet, but it does sound like a naming issue. My guess is there are elements in the scripts that have the same id or name.

Texas

6:22 pm on Apr 24, 2002 (gmt 0)

10+ Year Member



Hey txbakers, howzit going?

You're the person who REALLY helped me outa a jam here a while back. Thanks for jumping in.

As for me not being able to post a url, whoever this person is, they're responsible:

(edited by: Xoc at 5:17 pm (utc) on April 24, 2002) He/she also snipped th url from the code.

I didn't know I was breaking any forum rules; thought we could post urls.

Anyway, if you have a few free minutes, I'd appreciate your help.

Texas

(edited by: Texas at 8:14 pm (utc) on April 24, 2002)

jatar_k

6:33 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you will get snipped again you can look here for TOS

[webmasterworld.com...]

as txbakers said you can put the URL in your profile there by allowing people to see what you are refering to or you can stickymail them the url as well.

jatar_k

6:39 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



function loadornot(){
if (get_cookie('poppedup')==''){
openpopup();<<<<
document.cookie="poppedup=yes";<<<<
}
}

loadornot(); <<<<

<<<<shouldn't there be semicolons here?

<added>I get an "openpopup undefined" error in my debugger which is usually syntax problems

Texas

8:36 pm on Apr 24, 2002 (gmt 0)

10+ Year Member



Does anyone know of some other good forums to post this question...or maybe know of someone who offers a fee based service who can solve my dilemma?

I need to get this fixed.

Texas

korkus2000

9:04 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Place a name in your pop up.

winpops=window.open(popurl,"","width=260,height=200,")

winpops=window.open(popurl,"window1","width=260,height=200,")

Place semicolons at the end of every javascript line.

Also use unique names for your variables. popurl is really confusing and at the heart of your problem. popupCookieUrl and popupLinkUrl would be more informative.

Texas

12:47 am on Apr 25, 2002 (gmt 0)

10+ Year Member



Everything's OK now...I figured it out on my own. The answer was in front of me all along.

For the link-accessed popup, I simply used javascript:openpopup1() (adding the 1).

I left the cookie based popup in the body as is.

Works perfect. Visit profile url to see it in action if you're interested...

Texas

jatar_k

1:23 am on Apr 25, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm glad you go it working, I guess we were all a little asleep.
2 functions with the same name obviously won't work.
sorry we weren't more help

txbakers

2:19 am on Apr 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



but it does sound like a naming issue. My guess is there are elements in the scripts that have the same id or name.

Gee, didn't I say that around noon today?

Glad you got it fixed. I'd be glad to help you in the future as well. If it's an easy one no charge....