简体   繁体   English

我可以定位其他页面上的标签内容ID吗?

[英]Can I target id of tab-content from other page?

Can I target this tab content form another page? 我可以将此标签内容定位到其他页面吗?

<div class="container">
    <ul class="nav nav-pills nav-stacked" role="tablist" id="navbar4">
        <li role="presentation"> <a role="tab" data-toggle="tab" href="#id1">home</a></li>
        <li role="presentation">  <a role="tab" data-toggle="tab" href="#id2">profile</a></li>
        <li role="presentation">  <a role="tab" data-toggle="tab" href="#id3">about</a></li>
    </ul>

</div>


<div class="tab-content">
    <div role="tabpanel"
         class="tab-pane active" id="id1">
    </div>


    <div role="tabpanel"
         class="tab-pane" id="id2">
    </div>


    <div role="tabpanel"
         class="tab-pane" id="id3">
    </div>
</div>

In the old days, this was possible, but it is not possible now (there are exceptions). 在过去,这是可能的,但现在是不可能的(有例外)。

Browsers in days of old let us do anything with javascript, even read and write files, but that became problematic. 过去的浏览器让我们可以使用javascript做任何事情,甚至可以读写文件,但这变得成问题。 Some programers used this to take advantage of unsuspecting web users, and browser developers tightened up security. 一些程序员利用它来利用毫无戒心的Web用户,并且浏览器开发人员加强了安全性。

Now, each tab runs as a completely separate environment, and the other tabs and the users computer are protected. 现在,每个选项卡都作为完全独立的环境运行,其他选项卡和用户计算机受到保护。 Even pages with frames now are separated, so the code executed within the frame cannot be interfered with by code outside the frame. 现在即使具有框架的页面也被分离,因此框架内执行的代码不会受到框架外代码的干扰。 (A frame is like a browser window within a web page) The frame and the parent page can exchange messages, but DOM manipulation and other parts of the page are not accessible. (框架就像网页中的浏览器窗口一样)框架和父页面可以交换消息,但是无法访问DOM操作和页面的其他部分。

I mentioned that there are exceptions. 我提到有例外。 All browsers allow the coding of extensions or plugins. 所有浏览器都允许对扩展名或插件进行编码。 These extensions and plugins DO have permission to manipulate tabs, access the camera, or other computer services like the file system. 这些扩展名和插件确实具有操作选项卡,访问相机或其他计算机服务(如文件系统)的权限。 Like an App on your phone, the user gives these permissions to the extension by installing it. 就像手机上的应用程序一样,用户可以通过安装扩展程序来赋予这些权限。 The idea is that the user is requesting that behavior, so the behavior becomes acceptable. 想法是用户正在请求该行为,因此该行为变得可以接受。

If you need to manipulate tabs on the browser, look into coding a plugin or extension for the browser rather than a web page. 如果需要在浏览器上操作选项卡,请考虑为浏览器而不是网页编码插件或扩展。

If you need to manipulate bootstrap-tabs on a page, you are restricted to the web page that you are currently using. 如果需要操纵页面上的引导程序选项卡,则只能使用当前使用的网页。

Here is another exception that applies to a bootstrap tab (as opposed to a browser tab): 这是适用于引导程序选项卡(与浏览器选项卡相对)的另一个例外:

If you own the website that is being served on both browser tabs, you CAN control the page by using server-client communication. 如果您拥有同时在两个浏览器选项卡上提供的网站,则可以使用服务器-客户端通信来控制页面。

  1. Design your page to check the server for updates regularly. 设计页面以定期检查服务器是否有更新。
  2. Pass commands from page1 to the server that are read by page2. 将第1页中的命令从第1页传递到服务器。
  3. Have page2 update automatically when it sees the command from page1. 看到page1中的命令时,使page2自动更新。

Again, this requires that you have design control on both pages being served. 同样,这要求您对所投放的两个页面都具有设计控制权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM