DClarkeNZ
asked on
Javascript Window.Print() doesn't return to URL with Querystring attached
I have a simple button on my web page that does onclick="window.print();" and it works well. However when the print is completed and the view is returned to the page, there is no Querystring after the URL. It just says "http://myweb/rego.asp?" rather than "http://myweb/rego.asp?eid=55".
Some help would be wonderful.
Some help would be wonderful.
is it a button or link element you're using to trigger the print? Can you please post the html you're using to trigger it. If you are using an anchor <a> element then you'll need the href="#"
ASKER
<button onClick="window.print();">Print</button>
Current page URL is "https://mysite.com/registrations/MYC_Reports9awai.asp?eid=55"
When it returns to page it seams to refresh with "https://mysite.com/registrations/MYC_Reports9awai.asp?"
There's more than meets the eye on this one as I can't replicate your issue: http://jsbin.com/xurene.html?eid=55 with code http://jsbin.com/xurene/3/edit?html,output
ASKER
Your pages are html pages whereas mine as classic asp. I'm wondering whether asp pages do a 'refresh' once the print function is finished (or cancelled). So I checked to make sure there was no 'onload' functions or the like or any javascript that might be affecting this. All I could find is the following piece of code at the bottom of my <head> section. I'm not sure why it's there or what it is achieving.
<script>
//Page Highlighting
var url = window.location.toString()
$(document).ready(function(){
$('ul li a').each(function(){
var myHref= $(this).attr('href');
if( url.match( myHref )){
$(this).addClass('active');
}
});
});
</script>
All that you've mentioned shouldn't affect the issue you're having. I'm not an asp dev but I am aware of partial postbacks.
Can you post the link to your site or send me a private message with the link to the page? I'll get a better idea with that
Can you post the link to your site or send me a private message with the link to the page? I'll get a better idea with that
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Michel, I think you're on the money with that one.
Try changing your button to a link as confirmation of what Michel is saying. A link should give you the desired effect.
I do remember that a button within a form will submit it when the type is omitted (as Michel had indicated in his post)
Try changing your button to a link as confirmation of what Michel is saying. A link should give you the desired effect.
I do remember that a button within a form will submit it when the type is omitted (as Michel had indicated in his post)
ASKER
Perfect! I suspected a return parameter but had tried 'True' instead of 'False'. Duh - makes sense now thank you.