Current location: Hot Scripts Forums » General Web Coding » JavaScript » onclick question


onclick question

Reply
  #1 (permalink)  
Old 02-27-10, 03:33 PM
levd levd is offline
New Member
 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
onclick question

Hi there all,

I hope finding some help with a question i have about onclick.

On one of my sites i would like to to open a popup window, if someone clicks anywhere on the page so it must work on all links clicked.

Can someone help me with this?
Is it possible to do this like lets say just one time a day per visitor?

Thanks for the help!

Levd
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-28-10, 01:45 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Post your code if you want help.
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-28-10, 06:27 AM
levd levd is offline
New Member
 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
i found this code:
HTML Code:
<script language="JavaScript">
        if (navigator.cookieEnabled) {
            var pop_under = null;
            var pop_cookie_name = "so_cookie";
            var pop_timeout = 720;
            function pop_cookie_enabled() {
                var is_enabled = false;
                if (!window.opera && !navigator.cookieEnabled) return is_enabled;
                if (typeof document.cookie == 'string')
                    if (document.cookie.length == 0) {
                    document.cookie = "test";
                    is_enabled = document.cookie == 'test';
                    document.cookie = '';
                } else {
                    is_enabled = true;
                }
                return is_enabled;
            }
            function pop_getCookie(name) {
                var cookie = " " + document.cookie;
                var search = " " + name + "=";
                var setStr = null; var offset = 0;
                var end = 0; if (cookie.length > 0) {
                    offset = cookie.indexOf(search);
                    if (offset != -1) {
                        offset += search.length; end = cookie.indexOf(";", offset);
                        if (end == -1) {
                            end = cookie.length;
                        }
                        setStr = unescape(cookie.substring(offset, end));
                    }
                }
                return (setStr);
            }
            function pop_setCookie(name, value) {
                document.cookie = name + "=" + escape(value) + "; expires=Friday,31-Dec-50 23:59:59 GMT; path=/;";
            }
            function show_pop() {
                var pop_wnd = "http://www.igirl.tv/exports/golive/";
                var fea_wnd = "scrollbars=›esizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0";
                var need_open = true; if (document.onclick_copy != null)
                    document.onclick_copy();
                if (document.body.onbeforeunload_copy != null)
                    document.body.onbeforeunload_copy();
                if (pop_under != null) {
                    if (!pop_under.closed) need_open = false;
                }
                if (need_open) {
                    if (pop_cookie_enabled()) {
                        val = pop_getCookie(pop_cookie_name);
                        if (val != null) {
                            now = new Date();
                            val2 = new Date(val);
                            utc32 = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
                            utc2 = Date.UTC(val2.getFullYear(), val2.getMonth(), val2.getDate(), val2.getHours(), val2.getMinutes(), val2.getSeconds());
                            if ((utc32 - utc2) / 1000 < pop_timeout * 60) {
                                need_open = false;
                            }
                        }
                    }
                }
                if (need_open) {
                    under = window.open(pop_wnd, "", fea_wnd);
                    under.blur(); window.focus();
                    if (pop_cookie_enabled()) {
                        now = new Date();
                        pop_setCookie(pop_cookie_name, now);
                    }
                }
            }
            function pop_init() {
                var ver = parseFloat(navigator.appVersion);
                var ver2 = (navigator.userAgent.indexOf("Windows 95") >= 0 || navigator.userAgent.indexOf("Windows 98") >= 0 || navigator.userAgent.indexOf("Windows NT") >= 0) && (navigator.userAgent.indexOf('Opera') == -1) && (navigator.appName != 'Netscape') && (navigator.userAgent.indexOf('MSIE') > -1) && (navigator.userAgent.indexOf('SV1') > -1) && (ver >= 4); if (ver2) { if (document.links) { for (var i = 0; i < document.links.length; i++) { if (document.links[i].target != "_blank") { document.links[i].onclick_copy = document.links[i].onclick; document.links[i].onclick = show_pop; } } } } document.onclick_copy = document.onclick; document.onmouseup = show_pop;
            } pop_init();
        }
    </script>
But what does it exactly do? open a popup, set a cookie and when it expired it does it again? is this the only thing it does?

Thx,

LEVD

Last edited by job0107; 03-01-10 at 08:15 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 02-28-10, 01:51 PM
levd levd is offline
New Member
 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
This code seems to work pretty good, only i cant figure out how i can set it to open a the pop once a day per user.
Any help?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-01-10, 08:21 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Those are the functions.
Where is the code where you are actually invoking the functions?
And the rest of the HTML?
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie member, (semi)novice developer has a question WorkyMcWorkerson Script Requests 2 11-26-08 02:28 PM
Injecting a string into an If Statement ? nova912 PHP 4 07-21-06 03:04 PM
how to use onclick in php coolcoder HTML/XHTML/XML 2 05-31-06 01:40 PM
question and answer software jaydifox C/C++ 0 02-21-04 10:26 AM


All times are GMT -5. The time now is 12:49 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.