WookieeMonster
10-22-2003, 03:06 PM
I am extremely new to JavaScript, having just written my first script to try and achieve something on eBay. I've pieced this together from looking at other people's scripts, and looking at some brief tutorials on the net, so please bear with me if it's a mess or I'm doing something blatantly wrong!
So, here's my problem...
What I want to acheive is a popup window linked from within my auction listings, which contains my auction Terms & Conditions. This page has four named anchors - 'Top', 'Shipping', 'Payment' and 'Returns'.
Until now, I have been using a basic HREF link in the HTML with the TARGET="_BLANK" option - for example:
<A HREF="http://mysite.co.uk/common/popups/TandC.htm#Shipping" TARGET="_BLANK">
But I'm not happy with that! :p
Trying to be ever more professional with my listings, I want a basic popup window with only my page in it - a fixed width and height, no menus, no toolbars, no status bar, non-resizable and so on. Hence my turning to JavaScript.
Now, as you may know, eBay prevent you from using JavaScript to create popup windows directly from within your auction listings. :mad:
I figured I would get around this by linking to a redirection page using the HREF/TARGET="_BLANK" method. This page would contain the necessary JavaScript to create such a popup containing the actual Terms & Conditions page, and then close itself down.
So I changed my links to point to this page...
http://mysite.co.uk/ebay/popups/TandC.html
...which contains nothing but the basic HTML structure tags (HEAD, BODY etc.) and the script. This is the script:
function OpenTandC() {
baseURL = "http://mysite.co.uk/common/popups/TandC.htm#" ; // Base of new redirect URL
myWinTitle = "TandC" ; // Name of popup window
myWinOpts = "width=500,height=400,left=50,top=50,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resiz able=no" ; // Display and function options for the popup window
currentURL = location.href ; // URL of current page (prior to redirect)
hash_pos = currentURL.indexOf("#") ; // Look for # of named anchor
if (hash_pos == -1) { // If no # present in URL, default to 'Top'...
newURL = baseURL + "Top" ;
}
else { // ...otherwise get everything after the # which should be the name of the anchor
anchor_name = currentURL.substr(hash_pos + 1,currentURL.length - hash_pos + 1) ;
}
newURL = baseURL + anchor_name ; // Add the anchor name to the base URL
window.open(newURL,myWinTitle,myWinOpts) ; // Open the popup window
window.close() ; // And finally... close this window!
}
I tested this on my PC (running Windows XP Home Edition) during developing it, and it has worked perfectly. :)
Today I started an eBay auction using it, and again on my PC it worked perfectly. :D
But on a different PC running Windows ME, it gets stuck in a loop and keeps opening window after window, never displaying the actual Terms & Conditions page. :(
What am I missing/doing wrong? Or is it a glitch in ME or something on the other machine? :confused:
I've taken it out of the listing I started today and returned to the simple HTML TARGET="_BLANK" method for now, but I'd like to get it sorted and use it in future, if at all possible.
Any and all help/tips/pointers greatfully received!
So, here's my problem...
What I want to acheive is a popup window linked from within my auction listings, which contains my auction Terms & Conditions. This page has four named anchors - 'Top', 'Shipping', 'Payment' and 'Returns'.
Until now, I have been using a basic HREF link in the HTML with the TARGET="_BLANK" option - for example:
<A HREF="http://mysite.co.uk/common/popups/TandC.htm#Shipping" TARGET="_BLANK">
But I'm not happy with that! :p
Trying to be ever more professional with my listings, I want a basic popup window with only my page in it - a fixed width and height, no menus, no toolbars, no status bar, non-resizable and so on. Hence my turning to JavaScript.
Now, as you may know, eBay prevent you from using JavaScript to create popup windows directly from within your auction listings. :mad:
I figured I would get around this by linking to a redirection page using the HREF/TARGET="_BLANK" method. This page would contain the necessary JavaScript to create such a popup containing the actual Terms & Conditions page, and then close itself down.
So I changed my links to point to this page...
http://mysite.co.uk/ebay/popups/TandC.html
...which contains nothing but the basic HTML structure tags (HEAD, BODY etc.) and the script. This is the script:
function OpenTandC() {
baseURL = "http://mysite.co.uk/common/popups/TandC.htm#" ; // Base of new redirect URL
myWinTitle = "TandC" ; // Name of popup window
myWinOpts = "width=500,height=400,left=50,top=50,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resiz able=no" ; // Display and function options for the popup window
currentURL = location.href ; // URL of current page (prior to redirect)
hash_pos = currentURL.indexOf("#") ; // Look for # of named anchor
if (hash_pos == -1) { // If no # present in URL, default to 'Top'...
newURL = baseURL + "Top" ;
}
else { // ...otherwise get everything after the # which should be the name of the anchor
anchor_name = currentURL.substr(hash_pos + 1,currentURL.length - hash_pos + 1) ;
}
newURL = baseURL + anchor_name ; // Add the anchor name to the base URL
window.open(newURL,myWinTitle,myWinOpts) ; // Open the popup window
window.close() ; // And finally... close this window!
}
I tested this on my PC (running Windows XP Home Edition) during developing it, and it has worked perfectly. :)
Today I started an eBay auction using it, and again on my PC it worked perfectly. :D
But on a different PC running Windows ME, it gets stuck in a loop and keeps opening window after window, never displaying the actual Terms & Conditions page. :(
What am I missing/doing wrong? Or is it a glitch in ME or something on the other machine? :confused:
I've taken it out of the listing I started today and returned to the simple HTML TARGET="_BLANK" method for now, but I'd like to get it sorted and use it in future, if at all possible.
Any and all help/tips/pointers greatfully received!