Mod rewrite and javascript cookie

S

Stillpoint Media

First of all I confess, I do not know much about javascript. The
problem is the following.

I found a script to invoke a popup newsletter subscribe box using
jquery. However the script only works when accessed by the direct URL,
not via the SEO-friendly URL. So...

This works:
http://www.example.com/test/php?id=1

This doesn't:
http://www.example.com/test/1/seo-friendly

This is the javascript call. Thanks in advance!

<script type="text/javascript">
jQuery(document).ready(function(){
if (document.cookie.indexOf('visited=true') == -1) {
var fifteenDays = 0;
var expires = new Date((new Date()).valueOf() + fifteenDays);
document.cookie = "visited=true;expires=" + expires.toUTCString();
$.colorbox({width:"580px", inline:true, href:"#subscribe"});
}
});
</script>
 
S

Scott Sauyet

Stillpoint said:
I found a script to invoke a popup newsletter subscribe box using
jquery. However the script only works when accessed by the direct URL,
not via the SEO-friendly URL. So...

This works:http://www.example.com/test/php?id=1

This doesn't:http://www.example.com/test/1/seo-friendly

This seems unlikely to be a javascript issue, or even one with jQuery
or your jQuery plug-in, as they really tend to know nothing about the
content of a URL, just using them as a string of text.

This is the javascript call. Thanks in advance!

<script type="text/javascript">
  jQuery(document).ready(function(){
        if (document.cookie.indexOf('visited=true') == -1) {
                var fifteenDays = 0;
                var expires = new Date((new Date()).valueOf() + fifteenDays);
                document.cookie = "visited=true;expires=" + expires.toUTCString();
        $.colorbox({width:"580px", inline:true, href:"#subscribe"});
                }});

</script>

I don't see anything in there that launches a popup. It's possible
that the $.colorbox call does so, but you don't supply it a url. How
would it be able to distinguish between the two urls?

-- Scott
 
B

beegee

This works:http://www.example.com/test/php?id=1

This doesn't:http://www.example.com/test/1/seo-friendly

This is the javascript call. Thanks in advance!

<script type="text/javascript">
  jQuery(document).ready(function(){
        if (document.cookie.indexOf('visited=true') == -1) {
                var fifteenDays = 0;
                var expires = new Date((new Date()).valueOf() + fifteenDays);
                document.cookie = "visited=true;expires=" + expires.toUTCString();
        $.colorbox({width:"580px", inline:true, href:"#subscribe"});
                }});

</script>

You haven't included the code that shows the html anchor, #subscribe.
Colorbox is indeed a popup ( actually a div ). Normally href itself
would point to the url like href:"http://www.example.com/test/1/seo-
friendly". I'm not sure what the colorbox rules are for pointing to
an anchor. Try pasting the URL into the href: value and see what
happens.

Bob
 

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

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top