-1

I had a function in my application which calls other domain url, I'm struggling to open that url in a new window when the function is executed.

sample code:

$('#btn').onClick(function(){ //This code is in my application.
//callOtherfn is a function from external javascript code that i cant change, 
 //because that is from other source.     
 callOtherfn({
   'param1':'param1',
    'param2':'param2'
  })   
});

//external javascript library  sample.js
  function callOtherfn(params){
   top.window.location = "www.sample.com";
  }

Now my question is, can it be possible to open "www.sample.com" in a new window after calling "callotherfn" without disturbing my app? Right now it is opening in the same window.

rUI7999
  • 129
  • 1
  • 3
  • 20

1 Answers1

0

open in a new window:

  function callOtherfn(params){
   window.open("www.sample.com", '_blank', "");
  }
roberto tomás
  • 4,435
  • 5
  • 42
  • 71
  • I dont have access to this code, That is from other library. Im' calling it from my app – rUI7999 Apr 09 '17 at 16:25
  • Don't call that function. Write your own. If instead the external library is calling the function, you can change the object within your code like BuggeredLibrary.callOtherfn = – roberto tomás Apr 09 '17 at 17:28
  • Thing is that i had to call that function for sure in my case. I'm thinking to do something like "beforeonload" and call the "sample.com" to open in a new window – rUI7999 Apr 09 '17 at 18:09