views:

641

answers:

4

I own an image hosting site and would like to generate one popup per visitor per day. The easiest way for me to do this was to write a php script that called subdomains, like ads1.sitename.com ads2.sitename.com

unfortunatly most of my advertisers want to give me a block of javascript code to use rather than a direct link, so I can't just make the individual subdomains header redirects.I'd rather use the subdomains that way I can manage multiple advertisers without changing any code on page, just code in my php admin page. Any ideas on how I can stick this jscript into the page so I don't need to worry about a blank ads1.sitename.com as well as the popup coming up?

+2  A: 

I doubt you'll find much sympathy for help with pop-up ads.

Diodeus
I'm surprised you'd say that really, the cost of running such a website has made it almost a necessity for most imagehosts to run them. Most large imagehosts use popups and I'm asking for help to make it only appear 1 time for each visitor to lesson the annoyance.
A: 

At the risk of helping someone who wants to deploy popup ads (which is bound to fail due to most popup blockers anyway), why can't you just have the subdomains load pages that load the block of Javascript the advertisers give you?

Grant Wagner
Only issue with that is you end up with two pages, one being blank subdomain page and one being the page loaded by the jscript.
I haven't seen a popup since 1996, Well, something like that!
Rich Bradshaw
A: 

How about appending a simple window.close() after the advertising code? That way their popup is displayed and your window closes neatly.

I'm not sure that I've ever had a browser complain that the window is being closed. This method has always worked for me. (IE, Firefox, etc.)

unfortunatly most browsers think window.close() is malicious and don't allow it to close itself without at least prompting the user :(
A: 

Hey, cut the guy some slack. Popups might not be very nice, but at least he's trying to reduce the amount of them. And popup blockers are going to fix most of it anyway. In any case, someone else might find this question with more altruistic goals (not sure how they'd fit that with popups, but hey-ho).

I don't quite follow your question, but here's some ideas:

  • Look into Server Side Includes (SSI) to easily add a block of javascript to each page (though you could also do it with a PHP include instead)
  • Do your advertiser choosing in your PHP script rather than calling the subdomains
  • Decipher the javascript to work out what it's doing and put a modified version in the subdomain page so it doesn't need an additional popup. Shouldn't be too hard.
Mat