PDA

View Full Version : JavaScript Referrer Link to be Modified for Normal Window



supergirl
07-14-2005, 12:21 AM
Hello,

This is regarding a “Tell-a-Friend” type of program I purchased that is to be opened by a javascript popup.

With the increased use of firewalls/popup blockers out there, you might want to open this program in a new normal window, rather than as a popup.

Naturally <a href="thisprogram.com" TARGET="blank"> is the way to go, however, the question is...

How would you modify the link code (below) so that the referral page can still be displayed in a normal window.

This code is provided in their documentation:

<a href="#" onClick= "window.open('your-url-to-this-program.cgi?referrer= '+window.location.href,' ','width=420,height=420');return false;">Tell a Friend!</a>

-----------

I have tried the following, but it does not seem to refer a specific page:

<a href="http://www.mysite.com/cgi-bin/thisprogram/thisprogram.cgi?referrer" TARGET="blank">Tell a Friend</a>

-----------

Any assistance would be greatly appreciated.

Thank you for your time!
Supergirl

jscheuer1
07-14-2005, 03:13 AM
First of all, if a pop-up window is launched as a direct result of a user clicking on a link, as it is in this case, it almost never (I've never seen it) results in a browser blocking the pop up. The logic is, you clicked on it, you got it. Second, your syntax looks a tiny bit off, the space between the two red characters below could create problems if it is not the actual syntax recommended and the program has any problems dealing with unexpected spaces (problems perhaps only apparent to the referred friend when they try to visit your page from the link this program sends them):

window.open('your-url-to-this-program.cgi?referrer= '+window.location.href,' ','width=420,height=420');return false;Using it this way is more 'normal' and passes no space:

window.open('your-url-to-this-program.cgi?referrer='+ window.location.href,' ','width=420,height=420');return false;Now the equivalent to the whole thing rendered as a normal link is:

<a href="your-url-to-this-program.cgi?referrer=http://www.yourdomain.com/thispage.htm" target="_blank">Tell a Friend</a>Now this can be confusing so let me write it using what you used in your example:

<a href="http://www.mysite.com/cgi-bin/thisprogram/thisprogram.cgi?referrer=http://www.mysite.com/index.htm" target="_blank">Tell a Friend</a>That part in red is the absolute path to the page that you want referred to the program er, friend.

supergirl
07-14-2005, 06:33 AM
Oh I see, thanks a lot! So for a normal window, you need to be referrer-specific for each page. I will try that tomorrow.

About popup blocking - for some reason it is just the IE browser that is misbehaving. FireFox and Netscape are showing my tell-a-friend window just fine, but since, as you know, the majority still uses the IE, it is better to play it safe…

I’ve even decided not to pop up my home page from the Index page without tool/menubar (it makes a site look sophisticated, I don’t know why, but it is a bit risky, as we know that few visitors appreciate that type of unexpected window behavior).

JavaScripts are sooo much fun, except for popup windows…

jscheuer1
07-14-2005, 07:01 AM
Yes, it may be helpful to understand that putting ?referrer= after a URL just sends that data to that page or, in this case program, in the form of added information in its location.href value. The location.href value is equal to what shows in the address bar and represents the pages location and any additional information passed to it. The ? means that the actual location is done, what follows is information. So in your script version the window.location.href of the referring page is parsed out by javascript to be the page's location. In the non javascript version, we simply write out the literal address of the referring page. One advantage to this is that, if you wish, you can have all the pages on your site refer to your home page. This could be done in the javascript version as well by replacing '+window.location.href with http://www.yourpage.htm'. Using either method you could provide two links. One to refer this page (using the current page as the referrer) and one to refer the site (using the home page as the referrer).