简体   繁体   English

在框架页面上动态更改文本

[英]Changing text dynamically on a framed page

替代文字

Hello guys 大家好

I'm creating a little website for my Javascript course. 我正在为我的Javascript课程创建一个小网站。 I created a page with 3 frames as above in the image. 如上图所示,我创建了一个包含3帧的页面。

I don't know if it is possible to do that but what I want to do is: 我不知道是否可以这样做,但我想做的是:

When the visitor clicks on "PAGE A" from the FRAME MENU, the text "TEXT TITLE" in the FRAME HEADER is changed to "WELCOME TO A", or when he clicks "PAGE B", the text "TEXT TITLE" is changed to "WELCOME TO B". 当访客从FRAME MENU中单击“ PAGE A”时,FRAME HEADER中的文本“ TEXT TITLE”更改为“ WELCOME TO A”,或单击“ PAGE B”时,文本“ TEXT TITLE”更改了到“欢迎来到B”。

I know it's possible to load two pages by one click and therefore you could say why not load another page in the frame header, but it's not what I want to do. 我知道可以一键加载两个页面,因此您可以说为什么不在框架标题中加载另一个页面,但这不是我想要的。

Is it possible to do that by any means in javascript? 是否可以通过javascript以任何方式做到这一点?

Thanks 谢谢

Well, first suggestion - don't use frames. 好吧,第一个建议-不要使用框架。 It is very easy to include pages into each other, so just write little components like menu.html, top.html, mainpage.html and include those into your pages. 相互之间包含页面非常容易,因此只需编写一些小组件,例如menu.html,top.html,mainpage.html并将它们包含在您的页面中。

This makes page management much easier - you reuse the code and can make the pages from those little components. 这使页面管理变得更加容易-您可以重复使用代码,并可以使用这些小组件来制作页面。

Then when you click on the link you would just go to the page that has manu included, in the top you include the appropriate title and the main page. 然后,当您单击链接时,您将直接转到包含手册的页面,在顶部,您将包含相应的标题和主页。

If you use some server-side language you could pass the title of the header as a parameter. 如果您使用某些服务器端语言,则可以将标头的标题作为参数传递。

If you really want to go with frames you would need to do something like this: Main page with frames: 如果您真的想使用框架,则需要执行以下操作:带框架的主页:

<html>
<head>
<title>Frames Example 5</title>
</head>
<frameset cols="20%,80%">
<frame src="page1.htm" name="left_frame">
<frame src="page2.htm" name="right_frame">
</frameset>
</html> 

Page, that changes links: 页面,更改链接:

<html>
<head>
<title>frame 10</title>
<script language="JavaScript" type="text/javascript">
<!--
function change()
{
parent.left_frame.location="page3.htm";
parent.right_frame.location="page4.htm";
}
//-->
</script>
</head>
<body bgcolor="#ffffff" text="#000000">
<center>
Click the link below to change both frames.
<br />
<a href="javascript:change2()">change 2 frames</a>
</center>
</body>
</html> 

so, in your menu add this javascript and change the links and reference your frames. 因此,在您的菜单中添加此javascript并更改链接并引用您的框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM