home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 March
/
Chip_2000-03_cd.bin
/
zkuste
/
Delphi
/
kolekce
/
d345
/
varian
/
varianz_soubory
/
popup.js
< prev
next >
Wrap
Text File
|
2000-01-11
|
7KB
|
218 lines
// -- Global Variables -- //
var study = '882inta';
var s_hostname = 'www.zdnet.com';
var popup_page = '/include/ads/campaigns/pages/spnlinks/popup.html';
var frequency = 5;
var cookie_name = 'XNoPopup';
var cookie_domain = '.zdnet.com';
var cookie_date = 'Tue, 26-Sep-00 00:00:00 GMT';
var width = 360;
var height = 240;
var cookie_path = '/';
// -----------------------------------------------------/
// -- quick function to pull out the referer --/
// -----------------------------------------------------/
function get_referer() {
var referer = self.location.host+self.location.pathname+self.location.search;
return referer;
}
// -----------------------------------------------------/
// -- function to append to the query string --/
// -- checks to see if data has already been appended --/
// -----------------------------------------------------/
function append_url (url, append_name, append_string) {
var v = parseInt(navigator.appVersion.substring(0,1));
var append = new String();
if (( v > 3) && ((append_string == null) || (append_string == 'null')) ){
append = append_name+'=';
}
else {
append = append_name+'='+escape(append_string);
}
if (url.indexOf('?') == -1) {
url = url+'?'+append;
}
else {
url = url+'&'+append;
}
return url;
}
// -----------------------------------------------------/
// -- determines if popup window should go, intercepts
// -----------------------------------------------------/
function popup(url, freq, cname, domain, exp, w, h, path) {
var index;
var popup_url;
if ((document.cookie.lastIndexOf(cname)==-1) &&
(Math.floor(7654321.0*Math.random())%freq==0))
{
set_cookie(cname, exp, domain, path);
var v = parseInt(navigator.appVersion.substring(0,1));
// -- netscape 3.01 cleanup -- //
popup_url = append_url(url,'referer',get_referer());
if (is_domain(self.location.hostname)) {
popup_url = host_to_domain(self.location, popup_url);
}
else {
popup_url = domain_to_host(self.location, popup_url);
}
var pw = window.open(popup_url,
'thePopupWin', 'toolbar=no,location=no,' +
'directories=no,status=no,scrollbars=yes,' +
'menubar=no,width=' + w + ',height=' + h +
',dependent=yes');
if ((pw != null) &&
!((navigator.userAgent.indexOf('MSIE') != -1) && (v < 3)))
pw.opener = self;
// -- do the following for: netscape, IE except for IE4-- /
if ( (v >= 3) &&
(((navigator.userAgent.indexOf('MSIE') != -1) && v != 4) ||
!(navigator.userAgent.indexOf('MSIE') != -1) ) )
pw.focus();
}
}
// -----------------------------------------------------//
// -- change popup url from xyz.com to www.xyz.com
// -----------------------------------------------------//
function host_to_domain(url, popup_page) {
var redirect;
var newpath;
if (popup_page.indexOf('/') == 0) {
redirect = url.protocol+'//'+s_hostname+popup_page;
}
else {
if (popup_page.indexOf('http') == 0) {
redirect = popup_page;
}
else {
if (url.pathname.lastIndexOf('/') != -1){
newpath = url.pathname.substring(0, url.pathname.lastIndexOf('/')+1);
}
redirect = url.protocol+'//'+s_hostname+newpath+popup_page;
}
}
return(redirect);
}
// -----------------------------------------------------//
// -- change popup url from www.xyz.com to xyz.com
// -----------------------------------------------------//
function domain_to_host(url, popup_page) { //go from www.a.com to a.com
var redirect;
var newpath;
s_hostname = url.host.substring(url.host.indexOf('.')+1, url.host.length);
if (popup_page.indexOf('/') == 0) {
redirect = url.protocol+'//'+s_hostname+popup_page;
}
else {
if (popup_page.indexOf('http') == 0) {
redirect = popup_page;
}
else {
if (url.pathname.lastIndexOf('/') != -1){
newpath = url.pathname.substring(0, url.pathname.lastIndexOf('/')+1);
}
redirect = url.protocol+'//'+s_hostname+newpath+popup_page;
}
}
return(redirect);
}
// -----------------------------------------------------//
// -- close popup window
// -----------------------------------------------------//
function go_away() {
window.close();
}
// -----------------------------------------------------//
// -- open new window with survey, close popup window
// -----------------------------------------------------//
function jump_to_survey(url) {
var v = parseInt(navigator.appVersion.substring(0,1));
var pw = window.open(url + self.location.search, 'theSurveyWin',
'toolbar=no,location=no,directories=no,' +
'status=no,scrollbars=yes,menubar=yes');
window.close();
}
// -----------------------------------------------------//
// -- get the value of a var from the query string
// -----------------------------------------------------//
function get_search_val(url, name) {
var value = url.substring(url.indexOf(name)+name.length+1,url.length);
var v = parseInt(navigator.appVersion.substring(0,1));
if (url.indexOf(name) == -1){
return 'null';
}
if (v == 3) {
if (value == null) {
return 'null';
}
}
else {
if (value == false) {
return 'null';
}
}
if (value.indexOf('&') == -1) {
return unescape(value);
}
else {
value = value.substring(0, value.indexOf('&'));
return unescape(value);
}
}
// -----------------------------------------------------//
// -- set a cookie
// -----------------------------------------------------//
function set_cookie (cname, cexpires, cdomain, cpath) {
document.cookie = cname + '=true; expires=' + cexpires + '; path=/;' +
((cdomain != null) ? (' domain=' + cdomain) : '');
}
// -----------------------------------------------------//
// -- show count image, according to study
// -----------------------------------------------------//
function count_image () {
document.write("<IMG SRC='http://survey.cyberdialogue.com" +
"/webqnr/engine/count.gif?client=" + study +
"' WIDTH=1 HEIGHT=1>");
}
// -----------------------------------------------------//
// -- determine if hostname is domainmame or not
// -----------------------------------------------------//
function is_domain(url_hostname){
var value = url_hostname.substring(
url_hostname.indexOf('.')+1,
url_hostname.length).indexOf('.');
if (value == -1) {
return 1;
}
else {
return 0;
}
}