Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup link code - with no header script

Status
Not open for further replies.

chrissparkle

Programmer
Mar 27, 2006
50
NZ
I'm building an affiliate system on my website. The users get to choose an image to put on their website and they select and paste the code etc. The thing is, I need the link of the image to click and open up a popup window with height/width etc all defined by me.

I just want the user to copy and paste the simple link code, I don't want to have to give them secondary code that they must put in their header too.

Is there good solid javascript that will open a popup window with attributes but all defined within the <a href> ?
 
Is there good solid javascript that will open a popup window with attributes but all defined within the <a href> ?

If I'm understanding you correctly, you can put an onclick handler in the <a> tag to do a window.open() command. With that command, you can contol many different aspects of a popup window.



[small]"Mom........MEATLOAF!!!! DANG!!!![/small]
<.
 
Thanks guys I think I'm on the right track but the following doesnt work:

Code:
<a href="#" onclick="window.open ("[URL unfurl="true"]https://secure.bob.com.au/wl-start.cfm?wid=123",[/URL] "mywindow","menubar=1,resizable=1,width=350,height=250");">open open open</a>

Am I missing something?
 
It's the use of quotations, you have to use single quotes for the parameters of the window.open statement cause you are already within double quotes:

Code:
onclick="window.open ('[URL unfurl="true"]https://secure.bob.com.au/wl-start.cfm?wid=123',[/URL] 'mywindow','menubar=1,resizable=1,width=350,height=250")'>open open open</a>


Note the single quotes.




[small]"Mom........MEATLOAF!!!! DANG!!!![/small]
<.
 
ok thanks for that. I also had to add javscript to the 'window.open'. but now for some weird reason when i click this:

Code:
<a href="javascript:window.open ('[URL unfurl="true"]https://secure.registeracompany.com.au/wl-start.cfm?wid=#session.proid#',[/URL] 'mywindow','menubar=1,resizable=1,width=350,height=250');">open open open</a>

it opens up my popup window OK but the main browser window changes page too and goes a page which just says [object]. ???
 
on the href tag, yes you add javascript:, not needed on the onclick handler though.

You need to keep the window.open statement on your onclick tag.

href will keep the reference in the same window.


[small]"Mom........MEATLOAF!!!! DANG!!!![/small]
<.
 
Make the changes denoted in red:
Code:
<a href="[!]#[/!]" [!]onclick="[/!]window.open ('[URL unfurl="true"]https://secure.registeracompany.com.au/wl-start.cfm?wid=#session.proid#',[/URL] 'mywindow','menubar=1,resizable=1,width=350,height=250');[!]return false[/!]">open open open</a>

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
I have this and it works fine, though naturally I can't access your network:

Code:
<a href="#" onclick="window.open('[URL unfurl="true"]https://secure.bob.com.au/wl-start.cfm?wid=123',[/URL] 'mywindow','menubar=1,resizable=1,width=350,height=250')">open open open</a>

[small]"Mom........MEATLOAF!!!! DANG!!!![/small]
<.
 
OK guys... try this for completely off-the-wall...
Code:
<html>
<head><title>Sample Page</title>
<script type="text/javascript">
function showSrc(imgSrc) {
	var html = '<a href="[URL unfurl="true"]http://www.tek-tips.com"[/URL] title="Visit the Tek-Tips web site">';
	html += '<img src="' + imgSrc + '" alt="" width="100" height="80" border="0"/></a>';
	void(prompt('Copy the following code and paste it on to your page:', html));
}
</script>
</head>
<body>
<img src="sampleImage.jpg" onclick="showSrc(this.src)" />
</body>
</html>
Just another approach to the same problem... this time using prompt().

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
[cheers] for prompt!!

[small]"Mom........MEATLOAF!!!! DANG!!!![/small]
<.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top