收 藏 投 稿 繁 体 RSS 
站长吧-中国站长学习与交流的网站
首 页 运 营 学 院 建 站 论 坛
Web master8.net  
 网站运营  
  欢迎在本站发布信息,在线投递稿件请点这里。编辑QQ:4908220,欢迎联系交流。
业界动态 创业故事 推广研究 策划盈利 电子商务 企业平台
  站长工具
SEO查询 Whois查询 Pr查询 域名查询 IP查询 网页编辑器
 建站服务  
  如有建站意向,请尽快联系我们,以便安排时间... 建站服务 QQ4908220 QQ:4908220
作品展示 服务范围 服务流程 服务报价 联系方式 付款方式
文章正文  » 您的当前位置: 首页 >> 学院 >> 网页设计 >> 设计相关
利用JavaScript更新网站
  来源:互联网 | 时间:2008-02-28 | 浏览:   相关评论 | 报告错误 | 发布文章
【字号: | | 】 【背景色 杏仁黄 秋叶褐 胭脂红 芥末绿 天蓝 雪青 灰 银河白(默认色)
If 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.

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



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不仅可以帮助你立即更新网页内容,还可以节省你宝贵的时间。
master8
  • 上一篇:网站设计十大错误
  • 下一篇:方便、快捷地制作404页面

  • 我要投稿  打印本文  推荐本文  加入收藏  返回顶部  关闭窗口
    搜模板(www.somoban.com) 原创网站模板交易平台
    阿里妈妈再掀疯狂采购风,网站广告位严重告急,急召天下站长
    基于PHP+MySQL的整站、模块、插件开发等或者按需求实现相应功能;
基于各PHP主流建站系统CMS,BBS,BLOG等的模板定制,完全手写代码;
整站数据迁移或备份恢复;网页代码优化、重构;整站常规SEO优化;网站技术支持;
点击了解详情...
    站长论坛
    • 验证码: