链接到 JQTouch 站点中的非主页面板

发布于 2024-08-28 13:28:11 字数 353 浏览 4 评论 0原文

我正在尝试从外部站点创建一个链接,该链接到达我正在构建的 JQTouch 站点上的特定内部面板。但是,无论我在链接中使用什么锚标记,浏览器始终会打开 JQT 站点的主页面板。

例如,如果我尝试链接到官方 JQTouch 演示中的用户界面面板,我将使用 http ://www.jqtouch.com/preview/demos/main/#ui 但主面板显示在浏览器中,而不是我请求的子面板。

任何建议都将非常受欢迎。我可以控制链接站点和链接站点,因此需要调整代码。

谢谢

I'm trying to create a link from an external site that arrives at a particular, internal panel on a JQTouch site I'm building. However the browser always opens the home panel of the JQT site no matter what anchor tag I use in the link.

e.g. If I try to link to the User Interface panel in the official JQTouch demo I use http://www.jqtouch.com/preview/demos/main/#ui but the home panel shows in the browser and not the sub-panel I requested.

Any suggestions would be very welcome. I have control of the both the linked and linking sites so can tweak code is necessary.

Thanks

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

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

发布评论

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

评论(1

因为看清所以看轻 2024-09-04 13:28:11

根据源代码(http://code. google.com/p/jqtouch/source/browse/trunk/jqtouch/jqtouch.js) - jqTouch 将加载页面中首先添加了 current 类的部分。

jqtouch.js 第 179 行:

// Make sure exactly one child of body has "current" class
if ($('#jqt > .current').length == 0) {
  currentPage = $('#jqt > *:first');
} else {
  currentPage = $('#jqt > .current:first');
  $('#jqt > .current').removeClass('current');
}

// Go to the top of the "current" page
$(currentPage).addClass('current');
location.hash = '#' + $(currentPage).attr('id');
addPageToHistory(currentPage);

因此,最好的办法可能是在运行 jqtouch 源之前检查您的 window.location.hash 变量,并设置哪个哈希值存在于当前类中。

沿着这个启发式的思路:

<script include jquery>
<script>
var cur = document.location.hash;
if (cur) {
  $('.current').removeClass('current');
  $(cur).addClass('current');
}
</script>
<script include jqtouch>

According to the source code (http://code.google.com/p/jqtouch/source/browse/trunk/jqtouch/jqtouch.js) - jqTouch will load whatever portion of your page first has the current class added to it.

Line 179 of jqtouch.js:

// Make sure exactly one child of body has "current" class
if ($('#jqt > .current').length == 0) {
  currentPage = $('#jqt > *:first');
} else {
  currentPage = $('#jqt > .current:first');
  $('#jqt > .current').removeClass('current');
}

// Go to the top of the "current" page
$(currentPage).addClass('current');
location.hash = '#' + $(currentPage).attr('id');
addPageToHistory(currentPage);

So the best thing to do might be to check your window.location.hash variable before you run the jqtouch source, and set which ever hash is there to the current class.

Something along the lines of this heuristic:

<script include jquery>
<script>
var cur = document.location.hash;
if (cur) {
  $('.current').removeClass('current');
  $(cur).addClass('current');
}
</script>
<script include jqtouch>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文