+ -
当前位置:首页 → 问答吧 → [Javascript]超级新手问题

[Javascript]超级新手问题

时间:2013-10-11

来源:互联网

情况系咁,当我一个网页入面有3个frame,
分别系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
引用:<script language="Javascript">
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();" >
当我未login既情况下揿个button,
系显示唔到profile.html出黎
我估系因为红色部份错晒
但系又google唔到应该用咩code

sorry,如果我表达得唔清楚
有无师兄可以答下我

[ 本帖最后由 maxhim1234 於 2013-8-16 02:11 AM 编辑 ]

作者: maxhim1234   发布时间: 2013-10-11

用FRAMESET 整左中右?

有冇果版的CODE 睇睇?

作者: zero_man   发布时间: 2013-10-12

[del]

作者: zero_man   发布时间: 2013-10-12

引用:原帖由 zero_man 於 15/8/2013 04:50 PM 发表
用FRAMESET 整左中右?

有冇果版的CODE 睇睇?
指frameset既code?
引用:<html>
<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-8-16 12:13 AM 编辑 ]

作者: maxhim1234   发布时间: 2013-10-12

引用:原帖由 maxhim1234 於 2013-8-15 02:07 AM 发表
情况系咁,当我一个网页入面有3个frame,
分别系left,main同right

left frame系一个login system
未login之前系login.html
login左之后系logined.html

main frame得一个button

而我想做既就系,当login ...
parent.left.location
还有比较请用 == , 不是 =

作者: 邪炎印   发布时间: 2013-10-12

引用:原帖由 maxhim1234 於 2013-8-16 12:12 AM 发表
指frameset既code?
复制内容到剪贴板代码:function check()
{
if (top.left.location.href.indexOf("login.html") != -1)
{
top.right.location = "profile.html";
}
else
{
alert("Please login first!");
}
}

作者: zero_man   发布时间: 2013-10-12

引用:原帖由 於 16/8/2013 01:49 PM 发表



parent.left.location
还有比较请用 == , 不是 =
唔得, 更改后揿个button, button无反应
试过额外打document.write(parent.left.location)
乜都无出到
引用:原帖由 zero_man 於 16/8/2013 02:04 PM 发表
function check()
{
if (top.left.location.href.indexOf("login.html") != -1)
{
top.right.location = "profile.html";
}
else
{
alert("lease login first!");
}
}
都系唔得, 更改后揿个button都系无反应
试过额外打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

引用:原帖由 maxhim1234 於 2013-8-17 02:16 AM 发表

唔得, 更改后揿个button, button无反应
试过额外打document.write(parent.left.location)
乜都无出到
都系唔得, 更改后揿个button都系无反应
试过额外打document.write(top.left.location.href)
会出左undefi ...
梗系唔得, 因为 parent.left.location 出的唔系单纯的 login.html 呢个名,
佢系出 full location, 你想知佢出咩好简单, 你只要加句 alert(parent.left.location); 系个 if condition 前面就可以了

http://bookmarks.heliohost.org/testhtml/main.htm

[ 本帖最后由 邪炎印 於 2013-8-17 08:29 AM 编辑 ]

作者: 邪炎印   发布时间: 2013-10-12

引用:原帖由 邪炎印 於 17/8/2013 08:02 AM 发表


梗系唔得, 因为 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
复制内容到剪贴板代码:<html class="">
<!--<![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>
当中
复制内容到剪贴板代码:<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!");
}
}
复制内容到剪贴板代码: <li>
<div align="center"><a href="javascript:check();" target="content">My Profile</a></div>
</li>
就系button同function既部份
注:我份功课个网页有3个frame
分别系"header", "navigation_bar", "content"
唔该师兄

[ 本帖最后由 maxhim1234 於 2013-8-17 02:14 PM 编辑 ]

作者: maxhim1234   发布时间: 2013-10-12

引用:原帖由 maxhim1234 於 2013-8-17 02:04 PM 发表
好奇怪, 喺师兄你个网到揿, 系得既
但系当我自己更正返既时候, 个button点揿都无反应
咁我以为自己有野打错,索性将
login.html
logined.html
button.html
呢3个html既code直接copy去对应既file.
但系个 ...
经过实际测试 问题出在target上面 如果你将成段 function 搬去你 target的网页 或 删去 target 果句应可正常执行

作者: 邪炎印   发布时间: 2013-10-12

引用:原帖由 邪炎印 於 17/8/2013 04:50 PM 发表


经过实际测试 问题出在target上面 如果你将成段 function 搬去你 target的网页 或 删去 target 果句应可正常执行



即是将target="content"删去?删去后都不能正常执行
揿个button依然无反应
我将整个website upload上黎希望师兄你会发现到有咩问题
link:
解压密码已PMPM埋zero_man巴打, 希望亦都可以参详一下
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

引用:原帖由 maxhim1234 於 2013-8-17 05:44 PM 发表

即是将target="content"删去?删去后都不能正常执行
揿个button依然无反应
我将整个website upload上黎希望师兄你会发现到有咩问题
link:
解压 ...
http://bookmarks.heliohost.org/testhtml/test/index.html
几乎无改野, 正常, 无问题, 只系要将 != 改为 == 就成了

作者: 邪炎印   发布时间: 2013-10-12

引用:原帖由 邪炎印 於 17/8/2013 06:59 PM 发表


http://bookmarks.heliohost.org/testhtml/test/index.html
几乎无改野, 正常, 无问题, 只系要将 != 改为 == 就成了
已更改,都系唔得
试过俾另一个朋友试开,
佢用chrome都系同我一样,login前后都无反应
但系佢转ie开,login前后都系叫佢please login first
我尝试紧用其他方式去实现同一个效果

作者: maxhim1234   发布时间: 2013-10-12

引用:原帖由 maxhim1234 於 2013-8-18 01:02 AM 发表
已更改,都系唔得
试过俾另一个朋友试开,
佢用chrome都系同我一样,login前后都无反应
但系佢转ie开,login前后都系叫佢please login first
我尝试紧用其他方式去实现同一个效果
chrome 可能涉及 local 存取问题(可以参考error message), 因为我都试过用local开都系唔成功, 但用我的link开成功了
最好解决方法 可能就是要放弃用 frameset

ie9 firefox opera 我都成功

作者: 邪炎印   发布时间: 2013-10-12

引用:原帖由 邪炎印 於 18/8/2013 09:05 AM 发表

chrome 可能涉及 local 存取问题(可以参考error message), 因为我都试过用local开都系唔成功, 但用我的link开成功了
最好解决方法 可能就是要放弃用 frameset

ie9 firefox opera 我都成功
唔紧要, anyway thanks 巴打

作者: maxhim1234   发布时间: 2013-10-12