Why does this URL do different things depending on how it's activated?

ⅰ亾dé卋堺 提交于 2020-01-24 20:54:06

问题


In a related post (here) I discuss a problem I'm having with a URL action in a SQL Server Reporting Services report. I thought I had solved the problem, but I now realize that I haven't. (I'll update the related post in due course.)

I'm generating a URL using string concatenation, and using Javascript so the URL opens in a new browser tab. Here's the code that generates the URL, which I think is pretty standard:

="javascript:void(window.open('http://www.ic.gc.ca/app/opic-cipo/trdmrks/srch/viewTrademark?id="
+ Fields!applicationNoWithExtn.Value
+ "&lang=eng&tab=reg','_blank'))"

And here's an example of the URL that's generated when a value is inserted:

http://www.ic.gc.ca/app/opic-cipo/trdmrks/srch/viewTrademark?id=159511-00&lang=eng&tab=reg

The generated URL works. It takes you to an online database web page for a Canadian trademark having application number 159511-00 (you don't see the "-00" suffix on the web page, but it's the correct application number).

The problem is that when the user clicks the generated URL, the browser's print dialog opens immediately after the web page opens. That's very distracting; the user has to click Cancel to dismiss the print dialog. If the web page is reloaded or refreshed within the browser, the browser's print dialog opens again. However, if I copy the URL and paste it into a new browser tab, I get the desired web page without the print dialog. I don't get it; it's the identical URL, but the version of the URL generated by my application somehow triggers the print dialog, whereas a copy/pasted version of the identical URL doesn't. I've tried different browsers (Chrome, Edge and IE) and different machines, but I keep getting that print dialog when I click the URL generated by my application. If I change the code to generate a standard URL like http://google.com the generated standard URL works without triggering the print dialog. So the problem seems to be with the particular web site that I am accessing via the concatenated URLs shown above.

Can anyone explain what's going on and how I can suppress that print dialog?

来源:https://stackoverflow.com/questions/59260425/why-does-this-url-do-different-things-depending-on-how-its-activated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!