cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript execution blocked in development enviroment

Former Member
0 Kudos

Hi to all,

I need to print some iViews in webDynpro.

I have the following inplementation:

try {
      IWDWindow win = wdComponentAPI.getWindowManager().createExternalWindow(displayPrint(), "Print", false);
   win.setWindowSize(600,600);
   win.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
   win.removeWindowFeature(WDWindowFeature.TOOL_BAR);
   win.removeWindowFeature(WDWindowFeature.MENU_BAR);
   win.open();

    } catch (Exception e) {

   wdThis.wdGetReporteHistorialComponenteController().reportError("Error al intentar imprimir el reporte:" + e.toString());   

    }

  public java.lang.String displayPrint( )

  {

    //@@begin displayPrint()

    StringBuffer x = new StringBuffer();

    x.append("<html><head><script>");

    x.append("parent.print();");

    x.append("</script></head>");

    x.append("<body>Printing...<hr/><a href='javascript:close();'>CLOSE</a></body>");

    x.append("</html>");

   

    String linktoFile = "";

   

    try {

        byte[] b = null;

        b =  x.toString().getBytes("UTF-8");

        IWDCachedWebResource htmlFile = WDWebResource.getWebResource(b, WDWebResourceType.HTML);

        htmlFile.setResourceName("Print.htm");

        linktoFile = htmlFile.getURL();

    } catch (UnsupportedEncodingException e) {

        e.printStackTrace();

    } catch (WDURLException e) {

        e.printStackTrace();

    }

   

    return linktoFile;

    //@@end

  }

When I execute this code in my local enviroment It works fine and I can open the print preview from windows, but, in the development enviroment it doesn't work; it opens only the print.htm page, but the print preview from windows doesn't open and in the print.htm page I get an error from javascript.

I get the following error:

Message: Access is denied.

Line: 1

Char: 1

Code: 0

I think may be the server in development enviroment has a specific configuration that doesn't allow to execute the script.

Comparing the url generated between development enviroment and my local enviroment i find that in development enviroment the url generated contains the nex parameter: sap-wd-secure-id=

Dou you have this kind of problem?

Thans in advance.

Blanca

Accepted Solutions (0)

Answers (2)

Answers (2)

daniel_ruiz2
Active Contributor
0 Kudos

Hi Blanca,

I suppose you have your own local environment, which runs the WDJ Application 'straight away' being the 'parent' the window reference itself.. which is fine.. but when you deploy to your development environment, perhaps you are using Portal for instance where the WDJ Application doesn't really open on the top window of the HTML but instead, inside a frame element.

IF* this is the case, and* you want to really send the 'parent' frame to the Printer, you either need:

- Activate the domain relaxation on tc~wd~dispwda - should be ok for crossframes between WDJ;

- Or; start with a document.domain = 'yourServerDomainFromUpperFrame' in your script so you don't get a cross origin issue when trying to manipulate the parent frame;

Hope it helps,

D.

PS: Other than this, your IE (or w/e browser) could have some settings for the specific domain you are trying to reach, and block execution of scripts in that domain.. it's very unlikely thou, as the WDJ itself needs scripts to work.

former_member191044
Active Contributor
0 Kudos

Hi Blanca,

i'm not sure if this a proper way since "createExternalWindow()" is deprecated as far as i know.

You could try using WebWidget Ui Element for custome HTML (property html). This WebWidget you could assigne to a popup view and show it on purpose.

Regards

Tobias.