我如何改变&QUOT的URL;父"帧? [英] How do I change the URL of the "parent" frame?

查看:93
本文介绍了我如何改变&QUOT的URL;父"帧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我是主持人自己。我没有一个静态IP地址,所以我有掩蔽到我的DDNS帐户转发我的域名的所有流量。结果页面看起来像这样...

I have a website which I host myself. I do not have a static IP address so I have all traffic for my domain forwarded with masking to my DDNS account. The resulting page looks like this...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>mydomianname.com</title>
</head>
<frameset rows="100%,*" border="0">
  <frame src="http://myddns.dyndns.org/mydomainname" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>
</html>

我怎样才能为用户的子框架内导航更新父框架的网址是什么?

How can I update the URL of the "parent" frame as users navigate within the "child" frame?

更新:成功

我曾尝试这样做与JavaScript,但有一个问题得到正确的的href 我的javascript函数具有副作用(有两个窗户,开拓,有我主窗口去了错误的位置,或者使得它如此后退按钮不正常)。所有我需要的是我的的属性标签来保存,我可以在我的JavaScript中使用的值,但是会做没有别的都没有。添加归因事件虽然不是土生土长的属性添加到 A 标签的伟大工程。

I have tried doing this with javascript but had an issue getting the correct href to my javascript function with out having adverse side effects (having two windows open up, having my main window go to the wrong location, or making it so the back button didn't work right). All I needed was an attribute of my a tag to hold a value that I could use in my javascript, but would do nothing else at all. Adding the attributed value event though it is not a native attribute to the a tag works great.

A 标记...

<a onclick="url_update(this);" value="test/test.html" href="javascript:void(0);">test link</a>

和JavaScript函数...

and the javascript function...

function url_update(element){
    base_url = 'http://mydomain.com/';
    window.parent.location.href = base_url + element.getAttribute('value');
}

所产生的更新的URL是...

the resulting updated URL is...

http://mydomain.com/test/test.html

......,有没有提到pviously副作用$ P $的。

... and there are none of the previously mentioned side effects.

唯一的负面影响,我想修复是在浏览器窗口底部的信息栏中的链接的显示。现在它说的javascript :无效(0); 因为这是写在我的的href 属性,但我想它当链接以显示更新的URL悬停......什么想法?

The only "side effect" that I would like to fix is display of the link in the info bar at the bottom of a browser window. Right now it says javascript:void(0); because that is what is written in my href attribute, but I would like it to show the updated URL when the link is hovered over... any thoughts?

这将是更好,如果我能放弃这一切的JavaScript和使用IIS 7 URL重写2.0要做到这一点,而不是...但我还没有掌握URL重写的黑色艺术。

It would be even better if I could scrap all of this javascript and use IIS 7 URL Rewrite 2.0 to do this instead... but I have yet to master the black art of URL rewriting.

推荐答案

JavaScript的:

javascript:

window.top.location = 'anther url'

- 更新到更新的问题。

--UPDATE to your updated question

使用 element.getAttribute('值')而不是 element.value

- 更新#2
使用href属性,但是,添加一个返回false; 来的onclick功能:

--UPDATE #2 Use the href attribute, however, add a return false; to the onclick function:

<a onclick="url_update(this);return false;" value="test/test.html" href="test/test.html">test link</a>

一旦你这样做,你可能会跳过藏汉属性的值,只是使用在href属性,更新您的url_update函数中使用 element.href 而不是<$ C的$ C> element.value

这篇关于我如何改变&QUOT的URL;父&QUOT;帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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