Reputation: 7664
Current window
http://www.testing.com/default.aspx
or
http://www.testing.com/default.aspx?id=1
Pop Up Window
http://www.testing.com/default.aspx?p=1
or
http://www.testing.com/default.aspx?id=1&p=1
What I have is
<a target="_blank" onclick="window.open(document.location.href + '?&p=1')">
Print Page
</a>
which is a bit wrong as pop up will become
http://www.testing.com/default.aspx?id=1?&p=1
i just need a tweak.
Any idea?
Upvotes: 1
Views: 524
Reputation: 6825
You could do this a few ways... This is how I would make it work:
<a target="_blank" onclick="window.open(document.location.href + (document.location.href.indexOf('?') >= 0 ? '&p=1' : '?p=1'))">
Print Page
</a>
EDIT: Updated to put querystring appending in parentheses.
Upvotes: 3