在同一个页面 ,超链接用js 传值如何实现(局部传值)

左手青春右手年华 2016-04-20 12:40:25


问题如图所示:框架结构只有一个框架,点击栏目页面框架页内容会更新,当然这个不是提问的重点,在如图所示的同一个页面,2个局部位置(栏目列表位置,和面包屑导航位置,点击导航链接,这2个部位是不会跳转的),现在我希望点击A链接文字名称,,label自动更新A链接上的文字名称,点击B链接文字名称,,label自动更新B链接上的文字名称,js我很白痴的,望大侠们莫笑。
...全文
298 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
墨白一凡 2016-04-25
  • 打赏
  • 举报
回复
$("ul li").find("a").each(function(){ $(this).click(function(){ alert($(this).attr("href"));///跳转的页面 alert($(this).html())///info }) })
slwsss 2016-04-20
  • 打赏
  • 举报
回复
<li><a href="<%#Eval("Module_Url")%>" target="mainframe" onclick="s('<%#Eval("Operation_name")%>')"><%#Eval("Operation_name")%></a></li>
  • 打赏
  • 举报
回复

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.main{width:1000px; height:500px;}
.left{width:300px;height:400px;  background-color:#0033FF;float:left; }
.right{width:700px;height:400px; background-color:#006633; float:left;}
.top{width:1000px;height:100px; background-color:#0099FF; text-align:right; padding-right:200px; padding-top:50px;}
</style>
</head>

<body>
<div class="main">
<div class="top" id="biaoti">


    
    
</div>
<script>
    
    function s(v){
        document.getElementById('biaoti').innerHTML = v;
       // document.getElementById('#mainframe').setAttribute('src',t);return false;
    }
    </script>
<div class="left">
<ul>
<li><a href="guahao.html" target="mainframe" onclick="s('这是标题1')">11</li>
<li><a href="2.html" target="mainframe" onclick="s('这是标题2')">22</li>
<li><a href="3.html" target="mainframe" onclick="s('这是标题3')">33</li>
<li><a href="4.html" target="mainframe" onclick="s('这是标题4')">44</li>
</ul>

</div>
<div class="right">
  <iframe name="mainframe" id="mainframe" src="index.html" frameborder="no" scrolling="auto" width="100%" height="auto" allowtransparency="true"></iframe>
</div>

</div>

</body>
</html>
可以实现 但是在服务器控件无用啊
 <ul>
         <asp:Repeater ID="Repeater1" runat="server">
         <ItemTemplate>        
            <li><a href="<%#Eval("Module_Url")%>" target="mainframe"  OnClientClick="s('<%#Eval("Operation_name")%>')"><%#Eval("Operation_name")%></a></li>
        </ItemTemplate>
        </asp:Repeater>          		
          </ul>
  • 打赏
  • 举报
回复
引用 1 楼 slwsss 的回复:
function js函数(){document.getElementById('labelID').innerText=this.innerText}
这是我之前的代码

//函数定义
function show() {
    document.getElementById("TopControl1_menuname").innerText = document.getElementById("menu_name").innerText;
}
//栏目调用
  <asp:Repeater ID="Repeater1" runat="server">
         <ItemTemplate>        
            <li><a href="<%#Eval("Module_Url")%>" target="mainframe" id="menu_name" onclick="show();"><%#Eval("Operation_name")%></a></li>
        </ItemTemplate>
        </asp:Repeater>     
//获取值处标签定义
  <div id="here_area" class="fl">当前位置: <asp:Label ID="menuname" runat="server" ></asp:Label> </div>
问题:每次点不同链接名称, 始终显示第一行那个链接名称
slwsss 2016-04-20
  • 打赏
  • 举报
回复
function js函数(){document.getElementById('labelID').innerText=this.innerText}

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧