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.
DClarkeNZAsked:
Who is Participating?
 
Michel PlungjanIT ExpertCommented:
It is possible the button is submitting to current page.

Try

  <button onClick="window.print(); return false">Print</button>

which is what you also would do on a link
0
 
RobOwner (Aidellio)Commented:
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="#"
0
 
DClarkeNZAuthor Commented:
  <button onClick="window.print();">Print</button>

Open in new window


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?"
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
RobOwner (Aidellio)Commented:
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
0
 
DClarkeNZAuthor Commented:
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>

Open in new window

0
 
RobOwner (Aidellio)Commented:
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
0
 
RobOwner (Aidellio)Commented:
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)
0
 
DClarkeNZAuthor Commented:
Perfect!  I suspected a return parameter but had tried 'True' instead of 'False'.  Duh - makes sense now thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.