当前位置: 首页 > 网络学院 > 设计教程 > 设计理念 > 利用JavaScript更新网站

设计理念
Flash网页设计的优点与缺点
大学网站内容应该从简
设计适合所有浏览器的网站
高水平网站设计的三个主要规则
根据你的需要选择网站类型
网站内容翻译
文化影响网站本地化
改进网站的几条建议
创建吸引用户的确认网页
优化网站图片
设计小型网站的7条重要规则
运用免费工具检查链接系统
避免使用Splash引导页
数码摄影中避免出现高压缩率的图片
避免出现网站设计错误
网站外观设计也很重要
网站设计应该从简
合理安排网站文字内容
设计站点定义
网站内容比布局更重要

设计理念 中的 利用JavaScript更新网站


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1817 ::
收藏到网摘: n/a

Use_JavaScript_To_Dynamically_Update_Your_WebsiteIf you've been on the Internet for a while, you've probably seen numerous examples of JavaScript use. JavaScript is a powerful scripting language used to create special effects on your website, but did you know it can also be used as a very powerful web design tool?

你可能注意到很多网站运用JavaScript,的确,JavaScript是一种能够创造特殊效果的脚本语言,但你是否知道它可以作为一种强有力的网站设计工具呢?

Have you ever joined a new affiliate program or created a new publication that you wanted to add to your existing navigational set up, but dreaded having to manually add the links to every page on your site?

你是否希望加入一种新程序,或者希望在原导航系统中添加出版系统,而需要手工改动每一张网页的链接呢?

You can use JavaScript to enable you to dynamically update every page on your website with just one file. This technique is the same technology used by numerous syndication services on the Internet. It enables them to deliver dynamically updated content to every website in their program.

你可以利用JavaScript程序自动改变网站的每张网页。这项技术被网上的许多企业运用,帮助网站更新内容。

Before we begin, if you'd like to see an example of a navigational system that is dynamically displayed, visit Web-source.net. This website has over one thousand pages and each and every one of them displays its navigational system using JavaScript. If I want to add an additional link, I simply update one file and every page on the site is automatically updated.


开始介绍之前,你可以登录Web-source.net,浏览自动呈现的导航系统。这个网站包含一千多张网页,利用JavaScript每一张网页都可以呈现导航系统。如果希望添加其它链接,你只需要更新一个文件,这样所有网页都会自动更新。

The first step in setting up your JavaScript feed is to create the file that will contain your content. To do this, open a text editor such as NotePad and simply copy and paste your existing navigational setup into a new page. There is no need to begin the page with <HTML><HEAD>, etc. as you are only creating the feed for one section of your existing web page which already has those tags.

利用 JavaScript更新内容的第一步就是要创建一个包含网站内容的文件。创建文件时,打开类似于NotePad 的文本编辑器,把现存导航系统复制,然后粘贴到新建网页中。你没有必要首先修改<HTML><HEAD>等,因为你仅仅是修改现有网页,现有网页已经包含这些标签。

Once you've created your new page containing your navigational HTML, you'll now need to add some additional JavaScript coding to each line of your HTML. The first line of your new file will look like this: <!--

创建包含导航HTML的新网页以后,你需要在HTML内容中增加其它JavaScript编码。新文件的第一行应该这样:<!--

The next line will begin with "document.writeIn('" and end with "');" (without the quotes). Your first line of HTML will be placed between the beginning and ending coding. For every line of your original coding, you'll need to add the above-mentioned codes before and after. Note: Make sure you don't add any extra spaces, including at the end of each line, as JavaScript is very sensitive. Your new file will end with //--> on the last line.

下一行以"document.writeIn('"开始,以"');"结束(没有引号)。首行HTML编码放置在开始与结束编码之间。每一行原始编码,都需要在开始与结束前,添加上述编码。请注意:避免添加任何其它空格,包括每一行的结尾,因为JavaScript很敏感,并且新文件要以//-->结束。

Here's how your code might look:


编码形式如下:

<!-- document.writeln('<TABLE BORDER="0" ALIGN="Center">'); document.writeln('<TR>'); document.writeln('<TD>'); document.writeln('Your table content'); document.writeln('</TD>'); document.writeln('</TR>'); document.writeln('</TABLE>'); //-->

Each backslash () should be preceded with another backslash.

每一个()符号放置在另一个反斜线符号之前。

Example:

例如:

Each apostrophe (') should be preceded with a backslash.

每一个省略符号(')放置在反斜线符号之前。

Example: '
 
例如:'

You can include most HTML and JavaScript coding however, you cannot include JavaScript that must access another file to run.

你可以包含大多数HTML或者JavaScript编码,然而,却不能包含推进文件运行的JavaScript

After you've created your content and added the special JavaScript coding, you'll need to save your new file. Try to select a name that reflects your file such as navigate.js and make sure your filename is no longer than eight letters. Next, you'll need to create a new directory on your server where you store your HTML files. Name this directory "content" (without the quotes) and upload your new .js file in ASCII.

创建内容,增加特定JavaScript编码以后,你需要保存新文件。尽量选择一个可以反映文件性质的名称(例如:navigate.js),并且保证文件名不超过8个字母。其次,你必须在储存HTML的服务器中创建新目录。目录命名为“content”(没有引号),然后利用ASCII模式将.js文件上传。

Here's where the magic occurs... Place the following code in your HTML pages where you would like your navigate.js content to be displayed. Make sure you change the URL and direct it to your new .js file. The following code must be displayed exactly as it appears. Make sure there are no spaces after the first line of code.

这里显得有点不可思议。把以下编码放置到navigate.js文件内容将会呈现的网页中,确保可改变URL,使其与新.js文件链接。以下代码必须原样重现,第一行编码后不可以出现空格。
<SCRIPT language="JavaScript" src="http://www.yourdomain.com/content/yourfile.js"> </SCRIPT>

If you've followed the above steps correctly, your navigational system should now be displaying on your web page. If you are receiving a script error message, most of the time, it's due to an extra space at the end of a line or an extra or missing character. Make sure you go over your code very carefully. Once you've created your content feed and it is displaying your content, updating your file will be simple.

如果正确遵循以上步骤,导航系统应该正在呈现网页,如果收到原本错误信息,可能是末尾行出现了空格或者其它内容,也有可能是遗漏了其它内容。一旦创建目录之后,服务器就会呈现内容,上传文件就会很简单。

Use_JavaScript_To_Dynamically_Update_Your_Website

If you'd rather not have to code the JavaScript yourself, I use a great script called, Master Syndicator which will code your content for you. I highly recommend it. Web-source.net

如果不希望利用JavaScript,我推荐你使用Master Syndicator,这个程序会为你自己编辑目录,你可以登录Web-source.net,查看相关内容。

Using JavaScript to display your navigational set up can not only enable you to instantly update the content on every page of your website, but can also save you hours of valuable time.

运用JavaScript不仅可以帮助你立即更新网页内容,还可以节省你宝贵的时间。

评论 (0) All

登陆 | 还没注册?