如何使用jQuery打开一个新的HTML页面? [英] How to open a new HTML page using jQuery?

查看:1328
本文介绍了如何使用jQuery打开一个新的HTML页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我使用的是IBM Worklight,其中包含名为 file1.html 的主文件,然后创建了另一个名为 file2.html的html文件



我试图打开file2,但目前为止没有运气。我尝试了以下几段代码:
$ b


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


  2. $(div1)。load(file2.html); // div1是file1外部div的id


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


  4. window.openURL(file2.html);


这些都不起作用!有什么建议吗?

解决方案

如果你想使用jQuery,.load()函数是你正在使用的正确函数;



但您在示例2中的div1 id选择器中缺少



这应该是有效的:

  $(#div1)。load(file2.html ); 


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?

解决方案

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");

这篇关于如何使用jQuery打开一个新的HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆