How to open a new HTML page using jQuery?

Cute_Ninja picture Cute_Ninja · Oct 20, 2012 · Viewed 114.7k times · Source

So, I am using IBM Worklight where I have the main file called file1.html and then I created another html file called file2.html.

I am trying to open file2 but no luck so far. I tried following pieces of code:

  1. $(this).load("file2.html");

  2. $("div1").load("file2.html"); //div1 is the id for outer div of file1

  3. WL.App.openUrl("file2.html");

  4. window.openURL("file2.html");

And none of these worked! Any suggestions?

Answer

Habibillah picture Habibillah · Oct 20, 2012

use window.open("file2.html"); to open on new window,

or use window.location.href = "file2.html" to open on same window.