Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Open PDF in New Window from Code Behind using JavaScript

Open PDF in New Window from Code Behind using JavaScript

Scheduled Pinned Locked Moved ASP.NET
helpjavascripttoolsquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NTheOne
    wrote on last edited by
    #1

    Hello All, I want to open PDF file in new window on button click event from code behind through JavaSctipt. I am using below mentioned code for opening PDF file in new window.

    string PopUpWindowPage = @"E:\\\Prism4.pdf";
    string Script = "";
    Script += "<script id='PopupWindow'>";
    Script += "confirmWin = window.open(' " + PopUpWindowPage + "','" + 1 + "','scrollbars=yes,resizable=1, width=960,height=500,left=50,top=130,status');";
    Script += "</script>";
    if (!Page.IsClientScriptBlockRegistered("PopupWindow"))
    Page.RegisterClientScriptBlock("PopupWindow", Script);

    I get below mentioned error message while opening the PDF file in new window.

    Microsoft JScript runtime error: Access is denied.

    Can Anyone tell me whats the issue with above code or any other settings have to do? Thanks in Adv...

    L J 2 Replies Last reply
    0
    • N NTheOne

      Hello All, I want to open PDF file in new window on button click event from code behind through JavaSctipt. I am using below mentioned code for opening PDF file in new window.

      string PopUpWindowPage = @"E:\\\Prism4.pdf";
      string Script = "";
      Script += "<script id='PopupWindow'>";
      Script += "confirmWin = window.open(' " + PopUpWindowPage + "','" + 1 + "','scrollbars=yes,resizable=1, width=960,height=500,left=50,top=130,status');";
      Script += "</script>";
      if (!Page.IsClientScriptBlockRegistered("PopupWindow"))
      Page.RegisterClientScriptBlock("PopupWindow", Script);

      I get below mentioned error message while opening the PDF file in new window.

      Microsoft JScript runtime error: Access is denied.

      Can Anyone tell me whats the issue with above code or any other settings have to do? Thanks in Adv...

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2
      1. Check the file path is correct and accessible using normal window.open() method 2) try not using depricated method. There are general reasons for this error

      ***** Programme comme si dept soutien technique. est plein de tueurs en série et ils savent adresse de votre domicile. *****

      1 Reply Last reply
      0
      • N NTheOne

        Hello All, I want to open PDF file in new window on button click event from code behind through JavaSctipt. I am using below mentioned code for opening PDF file in new window.

        string PopUpWindowPage = @"E:\\\Prism4.pdf";
        string Script = "";
        Script += "<script id='PopupWindow'>";
        Script += "confirmWin = window.open(' " + PopUpWindowPage + "','" + 1 + "','scrollbars=yes,resizable=1, width=960,height=500,left=50,top=130,status');";
        Script += "</script>";
        if (!Page.IsClientScriptBlockRegistered("PopupWindow"))
        Page.RegisterClientScriptBlock("PopupWindow", Script);

        I get below mentioned error message while opening the PDF file in new window.

        Microsoft JScript runtime error: Access is denied.

        Can Anyone tell me whats the issue with above code or any other settings have to do? Thanks in Adv...

        J Offline
        J Offline
        jkirkerx
        wrote on last edited by
        #3

        You need a client script manager first. cs = clientscript manager

        Dim cs As ClientScriptManager = Me.Page.ClientScript
        Dim rsType As Type = Me.GetType()

        If (Not cs.IsClientScriptIncludeRegistered(rsType, "jquery")) Then
        cs.RegisterClientScriptInclude("jquery", cs.GetWebResourceUrl(rsType, "SC_Standard.jquery.js"))
        End If

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups