How to open a new HTML page using jQuery?

后端 未结 4 2004
日久生厌
日久生厌 2020-12-31 11:19

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 tryi

相关标签:
4条回答
  • 2020-12-31 11:32

    Use window.open("file2.html");

    Syntax

    var windowObjectReference = window.open(strUrl, strWindowName[, strWindowFeatures]);
    

    Return value and parameters

    windowObjectReference 
    

    A reference to the newly created window. If the call failed, it will be null. The reference can be used to access properties and methods of the new window provided it complies with Same origin policy security requirements.

    strUrl 
    

    The URL to be loaded in the newly opened window. strUrl can be an HTML document on the web, image file or any resource supported by the browser.

    strWindowName 
    

    A string name for the new window. The name can be used as the target of links and forms using the target attribute of an <a> or <form> element. The name should not contain any blank space. Note that strWindowName does not specify the title of the new window.

    strWindowFeatures 
    

    Optional parameter listing the features (size, position, scrollbars, etc.) of the new window. The string must not contain any blank space, each feature name and value must be separated by a comma.

    0 讨论(0)
  • 2020-12-31 11:33

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

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

    0 讨论(0)
  • 2020-12-31 11:39

    You need to use ajax.

    http://api.jquery.com/jQuery.ajax/

    <code>
    $.ajax({
      url: 'ajax/test.html',
      success: function(data) {
        $('.result').html(data);
        alert('Load was performed.');
      }
    });
    </code>
    
    0 讨论(0)
  • 2020-12-31 11:49

    If you want to use jQuery, the .load() function is the correct function you are after;

    But you are missing the # from the div1 id selector in the example 2)

    This should work:

    $("#div1").load("file2.html");
    
    0 讨论(0)
提交回复
热议问题