Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Cant use "&" in a window.open while appending vars..
Old 10-13-2011, 11:20 AM Cant use "&" in a window.open while appending vars..
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Hi Guys.

Im trying to do the following..
Code:
// Get referring URL
var ref = encodeURIComponent(document.referrer);

function openWindow(id,name)
{

window.open("http://hauntednipple.co.uk?id="+id ,name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450px,height=250px");
// End.
}
However I want to add a &refurl= to it..
But if I do the following.
It just stops at the & ( ampersand )
I cant URLencode it etc as it needs to be the "&" symbol in the url bar so the get request works!

Ive tried:
But it fails.. ( just opens the url up to the & char.. )

Code:
// JavaScript Document

var ref = encodeURIComponent(document.referrer);

function openWindow(id,name)
{
// Open IMsupporting window.
window.open("http://hauntednipple.co.uk?id="+ id +"&refurl=" + ref ,name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450px,height=250px");
// End.
}
Simply having the &MPERSAND here breaks it.. id +"&refurl
Thoughts?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE



Last edited by lynxus; 10-13-2011 at 11:29 AM..
lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
 
Register now for full access!
Old 10-13-2011, 12:40 PM Re: Cant use "&" in a window.open while appending vars..
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Change it to Unicode "\uFF06"
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 10-13-2011, 03:10 PM Re: Cant use "&" in a window.open while appending vars..
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Doesnt work as it outputs as that in the url ( address bar ) on the popup window..

It needs to be & otherwise the get request fails..
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 10-13-2011, 03:53 PM Re: Cant use "&" in a window.open while appending vars..
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
use
Code:
String.fromCharCode(38)
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-13-2011, 04:10 PM Re: Cant use "&" in a window.open while appending vars..
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Just build up the URL and GET string before you use it as a parameter to the window.open

Code:
<script type="text/javascript">
var aurl="http://www.worldssaddestsongs.com/";
var theurl= aurl + "?a=1" + "&b=" + 2;
</script>
<form>
<input type="button" value="Open Window" onclick="open_win(theurl)">
</form>
</body>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 10-20-2011, 03:35 AM Re: Cant use "&" in a window.open while appending vars..
Novice Talker

Posts: 10
Name: Umar Bukhari
Location: Pakistan
Trades: 0
Try this one
Code:
// JavaScript Document

var ref = encodeURIComponent(document.referrer);

function openWindow(id,name)
{
// Open IMsupporting window.
window.open("YOURLINK?id="+ id +"\&refurl=" + ref ,name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450px,height=250px");
// End.
}
angelsdev is offline
Reply With Quote
View Public Profile Visit angelsdev's homepage!
 
Reply     « Reply to Cant use "&" in a window.open while appending vars..
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23071 seconds with 12 queries