Forum Moderators: open
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)
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
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.
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)
[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.
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.
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