Dojo 根据 URL 参数选择要打开的选项卡

发布于 2024-10-10 07:43:45 字数 2092 浏览 4 评论 0原文

我在 SO ( Dojo: Select a tab加载时取决于 url 参数 ),但我仍然不太清楚这是如何从 URL 调用打开选项卡的。

这是我的 HTML。

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script LANGUAGE="JavaScript1.2" type="text/javascript" 
        src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"
        djConfig="usePlainJson : true, parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.TabContainer");
dojo.require("dojo.data.ItemFileReadStore");
</script>

<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css"/>
</head>

<body class="claro" >

<div dojoType="dijit.layout.BorderContainer" style="width: 100%; height: 100%;">
    <div dojoType="dijit.layout.ContentPane" region="top">
    HEADER
</div>
<div dojoType="dijit.layout.TabContainer" region="center">
    <div dojoType="dijit.layout.ContentPane" title="tab1">
        <A NAME="tab1help">TAB 1 HELP</A>
</div>

    <div dojoType="dijit.layout.ContentPane" title="tab2">
        <A NAME="tab1help">TAB 2 HELP</A>
    </div>
</div>
<div dojoType="dijit.layout.ContentPane" region="bottom">
FOOTER
</div>
</div>

<script language="Javascript1.2" type="text/javascript">
    SCRIPT HERE TO GENERATE DIV CONTENT
</script>


</body>
</html>

底部的 javascript 生成其中包含锚点的 DIV 内容。访问此页面的方法是简单地指定“help.html”。

问题是如何在 URL (help.html) 中指定打开此页面并根据 URL 打开选项卡 2(或选项卡 1、或选项卡 5?)。有可能做到这一点吗?

作为背景,这是一个帮助页面,包含大约 10 个主题(每个主题都有一个选项卡),并作为卫星窗口打开。我需要能够打开特定选项卡并转到锚点,具体取决于冲浪者在主网络应用程序窗口中需要帮助的帮助功能。

非常感谢! 珍妮

I found this page on SO ( Dojo: Select a tab on load depending on url parameter ) but I'm still not very clear on how this opens a tab from a URL call.

Here's my HTML.

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script LANGUAGE="JavaScript1.2" type="text/javascript" 
        src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"
        djConfig="usePlainJson : true, parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.TabContainer");
dojo.require("dojo.data.ItemFileReadStore");
</script>

<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css"/>
</head>

<body class="claro" >

<div dojoType="dijit.layout.BorderContainer" style="width: 100%; height: 100%;">
    <div dojoType="dijit.layout.ContentPane" region="top">
    HEADER
</div>
<div dojoType="dijit.layout.TabContainer" region="center">
    <div dojoType="dijit.layout.ContentPane" title="tab1">
        <A NAME="tab1help">TAB 1 HELP</A>
</div>

    <div dojoType="dijit.layout.ContentPane" title="tab2">
        <A NAME="tab1help">TAB 2 HELP</A>
    </div>
</div>
<div dojoType="dijit.layout.ContentPane" region="bottom">
FOOTER
</div>
</div>

<script language="Javascript1.2" type="text/javascript">
    SCRIPT HERE TO GENERATE DIV CONTENT
</script>


</body>
</html>

The javascript at the bottom generates DIV content that has anchors in it. The way to get to this page is by simply specifying "help.html".

Question is how do I specify in the URL (help.html) to open this page and open tab 2 (or tab 1, or tab 5?) depending on the URL. Is it even possible to do this?

As background, this is a help page that has about 10 topics (each with a tab) and it opens as a satellite window. I need to be able to open a particular tab and go to the anchor depending on what help function the surfer needs help with in the main web app window.

Many thanks!
Janie

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三生殊途 2024-10-17 07:43:45

首先需要添加查询参数或者使用hash来指定要显示的主题编号,例如可以使用 help.html?topic=1help.html#1。当页面加载时,您可以从 URL 中获取主题编号。

然后获取选项卡容器的引用,根据主题编号选择对应的选项卡。例如:

var tabContainer = dijit.byId("myTab");
var topicNumber = 5; // Get from URL
tabContainer.selectChild(tabContainer.getChildren()[topicNumber - 1]); // Assume that to the topic number starts from 1 

您还可以尝试为每个选项卡分配 id,例如主题编号 1 为 topic1。然后

tabContainer.selectChild(dijit.byId("topic" + topicNumber));

First of all, you need to add query parameter or use hash to specify the topic number to display, for example, you can use help.html?topic=1 or help.html#1. When the page is loaded, you can get the topic number from the URL.

Then get the reference of the tab container and select the corresponding tab according to the topic number. For example:

var tabContainer = dijit.byId("myTab");
var topicNumber = 5; // Get from URL
tabContainer.selectChild(tabContainer.getChildren()[topicNumber - 1]); // Assume that to the topic number starts from 1 

You can also try to assign the id to each tab, for example, topic1 for topic number 1. Then

tabContainer.selectChild(dijit.byId("topic" + topicNumber));
放低过去 2024-10-17 07:43:45

您可以使用 php include。

<div dojoType="dijit.layout.ContentPane" title="tab1">
    <?php include 'help.php';?>
</div>

You can use php include.

<div dojoType="dijit.layout.ContentPane" title="tab1">
    <?php include 'help.php';?>
</div>
病毒体 2024-10-17 07:43:45

我所做的所有研究都表明这不能通过 URL 调用来完成。事实证明,您通过添加选定的参数来打开选定的选项卡...下面的示例...

<div dojoType="dijit.layout.ContentPane" title="HELP" selected="true">

谢天谢地,我没有静态页面(它们是通过 Catalyst 生成的),因此我可以动态生成真实条件。

如果其他人有同样的问题,希望这会有所帮助。杰威

All research I have done indicates that this can't be done from a URL call. Turns out that you open a selected tab by adding the parameter selected... example below......

<div dojoType="dijit.layout.ContentPane" title="HELP" selected="true">

Thankfully I don't have static pages (they are generated via Catalyst ) so I can generate the true condition dynamically.

Hopefully this will help if someone else has the same question. JW

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文