[Javascript]超级新手问题
时间:2013-10-11
来源:互联网
分别系left,main同right
left frame系一个login system
未login之前系login.html
login左之后系logined.html
main frame得一个button
而我想做既就系,当login左之后
只要我一揿个button,right frame就会显示profile.html
如果未login就揿个button, 就会有window.alert出现。
问题黎喇
以下系main frame既code
function check(){
if(parent.left="logined.html"){
top.right.location=("profile.html");
}
else {
window.alert(" Please login first! ");
}
}
</script>
......
.......
<input type="button" name="login" id="login" value="Login" onClick="check();" >
系显示唔到profile.html出黎
我估系因为红色部份错晒
但系又google唔到应该用咩code
sorry,如果我表达得唔清楚

有无师兄可以答下我
[ 本帖最后由 maxhim1234 於 2013-8-16 02:11 AM 编辑 ]
作者: maxhim1234 发布时间: 2013-10-11
有冇果版的CODE 睇睇?
作者: zero_man 发布时间: 2013-10-12
作者: zero_man 发布时间: 2013-10-12
用FRAMESET 整左中右?
有冇果版的CODE 睇睇?
<head></head>
<frameset cols="50%,*,*" border="1">
<frame src="login.html" name="left">
<frame src="button.html" name="main">
<frame src="nonprofile.html" name="right">
</frameset>
<body>
</body>
</html>
作者: maxhim1234 发布时间: 2013-10-12
情况系咁,当我一个网页入面有3个frame,
分别系left,main同right
left frame系一个login system
未login之前系login.html
login左之后系logined.html
main frame得一个button
而我想做既就系,当login ...
还有比较请用 == , 不是 =
作者: 邪炎印 发布时间: 2013-10-12
指frameset既code?
{
if (top.left.location.href.indexOf("login.html") != -1)
{
top.right.location = "profile.html";
}
else
{
alert("Please login first!");
}
}
作者: zero_man 发布时间: 2013-10-12
parent.left.location
还有比较请用 == , 不是 =
试过额外打document.write(parent.left.location)
乜都无出到
function check()
{
if (top.left.location.href.indexOf("login.html") != -1)
{
top.right.location = "profile.html";
}
else
{
alert("

}
}
试过额外打document.write(top.left.location.href)
会出左undefined
=====
额外问一条问题,其实有无一条code系可以显示到某一个frame指向边个html?

即系document.write(code)
可以出到xxxx.html咁?
唔该师兄
[ 本帖最后由 maxhim1234 於 2013-8-17 02:20 AM 编辑 ]
作者: maxhim1234 发布时间: 2013-10-12
唔得, 更改后揿个button, button无反应
试过额外打document.write(parent.left.location)
乜都无出到
都系唔得, 更改后揿个button都系无反应
试过额外打document.write(top.left.location.href)
会出左undefi ...
佢系出 full location, 你想知佢出咩好简单, 你只要加句 alert(parent.left.location); 系个 if condition 前面就可以了
http://bookmarks.heliohost.org/testhtml/main.htm
[ 本帖最后由 邪炎印 於 2013-8-17 08:29 AM 编辑 ]
作者: 邪炎印 发布时间: 2013-10-12
梗系唔得, 因为 parent.left.location 出的唔系单纯的 login.html 呢个名,
佢系出 full location, 你想知佢出咩好简单, 你只要加句 alert(parent.left.location); 系个 if condition 前面就可以了
http://bo ...
但系当我自己更正返既时候, 个button点揿都无反应
咁我以为自己有野打错,索性将
login.html
logined.html
button.html
呢3个html既code直接copy去对应既file.
但系个button都系无反应.....

当我正式运用师兄既CODE落我真正份功课既时候, 都系无反应
以下系我份功课该页既code
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>未命名文件</title>
<link href="boilerplate.css" rel="stylesheet" type="text/css">
<link href="Untitled-1.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
background-image: url(image/bg.png);
background-repeat: repeat;
}
</style>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css">
<script src="respond.min.js"></script>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script language="Javascript">
function check()
{
if(parent.header.location.toString().search("header.html") != -1)
{
top.content.location=("profile.html");
}
else
{
window.alert("lease login first!");
}
}
</script>
</head>
<body>
<div class="gridContainer clearfix"></div>
<div align="center"></div>
<table width="100%" border="0" align="center">
<tr>
<td width="10%" height="74"> </td>
<td><ul id="navigation_bar" class="MenuBarHorizontal">
<li>
<div align="center"><a href="javascript:check();" target="content">My Profile</a></div>
</li>
</ul></td>
<td width="10%"> </td>
</tr>
</table>
<p align="center"> </p>
<div align="center"> </div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("navigation_bar", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>
function check()
{
if(parent.header.location.toString().search("header.html") != -1)
{
top.content.location=("profile.html");
}
else
{
window.alert("lease login first!");
}
}
<div align="center"><a href="javascript:check();" target="content">My Profile</a></div>
</li>
注:我份功课个网页有3个frame
分别系"header", "navigation_bar", "content"
唔该师兄
[ 本帖最后由 maxhim1234 於 2013-8-17 02:14 PM 编辑 ]
作者: maxhim1234 发布时间: 2013-10-12
好奇怪, 喺师兄你个网到揿, 系得既
但系当我自己更正返既时候, 个button点揿都无反应
咁我以为自己有野打错,索性将
login.html
logined.html
button.html
呢3个html既code直接copy去对应既file.
但系个 ...
作者: 邪炎印 发布时间: 2013-10-12
经过实际测试 问题出在target上面 如果你将成段 function 搬去你 target的网页 或 删去 target 果句应可正常执行

揿个button依然无反应
我将整个website upload上黎希望师兄你会发现到有咩问题

link:
解压密码已PM

login system既account同password系
ac:test01
pw:123456
我想做到既系, 未login就揿「my profile」既话,
会有window.alert出现
login后揿「my profile」既话, 就可以link去profile.html
唔该师兄
[ 本帖最后由 maxhim1234 於 2013-8-17 06:02 PM 编辑 ]
作者: maxhim1234 发布时间: 2013-10-12
即是将target="content"删去?删去后都不能正常执行

揿个button依然无反应
我将整个website upload上黎希望师兄你会发现到有咩问题

link:
解压 ...
几乎无改野, 正常, 无问题, 只系要将 != 改为 == 就成了
作者: 邪炎印 发布时间: 2013-10-12
http://bookmarks.heliohost.org/testhtml/test/index.html
几乎无改野, 正常, 无问题, 只系要将 != 改为 == 就成了
试过俾另一个朋友试开,
佢用chrome都系同我一样,login前后都无反应
但系佢转ie开,login前后都系叫佢please login first
我尝试紧用其他方式去实现同一个效果

作者: maxhim1234 发布时间: 2013-10-12
已更改,都系唔得
试过俾另一个朋友试开,
佢用chrome都系同我一样,login前后都无反应
但系佢转ie开,login前后都系叫佢please login first
我尝试紧用其他方式去实现同一个效果

最好解决方法 可能就是要放弃用 frameset
ie9 firefox opera 我都成功
作者: 邪炎印 发布时间: 2013-10-12
chrome 可能涉及 local 存取问题(可以参考error message), 因为我都试过用local开都系唔成功, 但用我的link开成功了
最好解决方法 可能就是要放弃用 frameset
ie9 firefox opera 我都成功

作者: maxhim1234 发布时间: 2013-10-12
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28