-3
function print(){
var URL2 = "C:/print/line/nameofpdf"
URL2 = URL2 + ".pdf"; //here after this please tell what logic should i write
}

I have to display a PDF on a button click in a popup window .So on the button click i am calling one function and i have path of the location where the PDF is stored in my local . Please note that i have to reload the parent page on closing the window where we are displaying the PDF and i have to perform the task using JAVASCRIPT.

user4188607
  • 9
  • 1
  • 7
  • 2
    http://stackoverflow.com/questions/7727045/how-to-open-a-pdf-file-new-browser-window-in-javascript – caramba Aug 11 '15 at 09:37
  • Using this I am getting one error on the JSP page that Naivgator is null or not an object – user4188607 Aug 11 '15 at 09:45
  • on closing the popup window i want parent window to be refreshed or reloaded : help please its urgent – user4188607 Aug 11 '15 at 10:20
  • copy paste your comment and the first google result is: http://stackoverflow.com/questions/10792408/open-popup-and-refresh-parent-page-on-close-popup – caramba Aug 11 '15 at 10:54

1 Answers1

1

This issue can happen with JSP pages. One workaround is as follows :-

Create an html file say 'redirect.html' with the following content.

*

<html>
<head>
<script type="text/javascript">
function print() {
    var URL2 = "C:\\print\\line\\nameofpdf"
        URL2 = URL2 + ".pdf"; 
    return URL2;
}
</script>
<head>
<body>
<script type="text/javascript">
location.href = print();
</script>
</body>
</html>

*

In your jsp file use code window.open("redirect.html");

This should fix your concern.

Ajmal E S
  • 57
  • 4
  • If you want to pass the URL as an argument, you can go ahead with that also.. all the best :) – Ajmal E S Aug 11 '15 at 10:50
  • @caramba i tried that approach that u suggested for closing functionality window.onbeforeunload = null; window.open(URL2, "", "dialogheight:350px;dialogwidth:700px;help:no;resizable:yes;scroll:yes;status:no;titlebar:yes;"); window.onunload = refreshParent; function refreshParent() { window.opener.location.reload(); window.close(); – user4188607 Aug 11 '15 at 12:44
  • @ caramba : when the popup is opening then only the refreshParent is being called and eventhough i am calling this function on window.onunload =refreshParent; whereas it should be called when the pdf window is closed So i think when i amclicking on print button (its an unload ) and immediately my child pdf window is opening ) please help – user4188607 Aug 11 '15 at 12:48
  • Is the new window getting opened? What is the URL getting displayed? – Ajmal E S Aug 11 '15 at 13:00
  • no it is showing some exception that class not found and the html name – user4188607 Aug 11 '15 at 13:05
  • my url is dynamic and is not fixed so please tell some approach that fits here in the parent page – user4188607 Aug 11 '15 at 13:06
  • You can call redirect.html with parameters like redirect.html?url='yourURL'. Then you can retrieve the value from redirect.html. You can refer some link like below to see how to do that. May be making it little complicated. But surely this is one way. http://stackoverflow.com/questions/827368/using-the-get-parameter-of-a-url-in-javascript – Ajmal E S Aug 11 '15 at 13:41