0

I have a link in the page.On clicking the link the pop up should render with required url.I have the window.open code as follows

<a href="javascript:;" onclick="window.open('/action.do?name=aravind&age=19&url=http://astrik.com/click?id=613*B&offerValue=2.9','chatWindow','menubar=1, scrollbars=yes, resizable=yes, width=600,height=450');return false;">Click here</a>

on clicking above link the popup is opening with url upto http://astrik.com/click?id=613*B and offerValue is not showing up in the url of pop up.I need the offerValue to be shown in the url.Any reason for not showing up the offerValue.

3

3 Answers 3

0

The provided URL contains a ? that indicates the start of an argument list. Each argument is separated by an &. Thus, for the parser the provided argument list look like this:

name=aravind, age=19, url=http://astrik.com/click?id=613*B and offerValue=2.9. They all belong to the request to /action.do.

You need to escape the last amp with its URL escape code %26 like this:

/action.do?name=aravind&age=19&url=http://astrik.com/click?id=613*B%26offerValue=2.9

to "bind" the last argument to the astrik URL. Maybe it is also required to escape the second ? with %3F.

0

You should escape the data parts in url's before using it. In this case the data part url is bugged by the ampersand(&) in the url.

var url = encodeURIComponent('http://astrik.com/click?id=613*B&offerValue=2.9');


<a href="javascript:void(0);" onclick="window.open('/action.do?name=aravind&age=19&url=' + url,'chatWindow','menubar=1, scrollbars=yes, resizable=yes, width=600,height=450');return false;">Click here</a>

(or just replace the ampersand, not sure now)

0

Try the following:

<a href="javascript:;" onclick="window.open('/action.do?name=aravind&age=19&url=http://astrik.com/click?id=613*B%26offerValue=2.9','chatWindow','menubar=1, scrollbars=yes, resizable=yes, width=600,height=450');return false;">Click here</a>

You must URL encode your parameters for the "url" value, otherwise they will get appended to the original URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.