May 31. 2006 0 Comments
- Posted in:
A colleague of mine was having a problem with this issue yesterday.
If you are passing a URL with its own complex query string in an HREF tag to a popup (window.open / showModalDialog, etc.), remember to do this:
<a href=”#” onclick=”window.open('foo.aspx?id=1&url=bar.aspx%3fvar1%3dONE%26var2%3dTWO')”>click me</a>
<a href=”window.open('foo.aspx?id=1&url=bar.aspx%3fvar1%3dONE%26var2%3dTWO')”>click me</a>
In the example above, I am trying to pass url “bar.aspx?var1=ONE&var2=TWO” tofoo.aspx when the popup window is opened.
There seems to be something about how the href tag is handled that when you do the method below (passing window.open...) inside the href tag, you will be guaranteed to lose var2=TWO
Give it a try. It's weird, but interesting to know nonetheless.