客户端包含JavaScript [英] Client-side includes with JavaScript

查看:99
本文介绍了客户端包含JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JavaScript在客户端模拟服务器端包含

。我的主要问题是:有没有办法以某种方式

将变量传递给这样的指令:


< SCRIPT LANGUAGE =" JavaScript" type =" text / javascript"

src =" $ myPageVar $">< / SCRIPT>

....其中$ myPageVar $是一个变量我已经声明了,不知何故,

神奇地,它的值被放入这个指令中?如果我在

中以下列方式为$ myPageVar $硬编码一个值,那么我唯一可以获得此功能的方法就是:


< SCRIPT LANGUAGE =" JavaScript" type =" text / javascript"

src =" homeInc.js">< / SCRIPT>

....这是有限的用途。有没有办法让我在

这样的指令中使用变量?或者有没有更好的方法来做客户端

包括?


谢谢。

解决方案

myPageVar


">< / SCRIPT>

.... where


< BLOCKQUOTE> myPageVar

I''m trying to simulate server-side includes on the client-side by
using JavaScript. My main problem is this: is there a way to somehow
pass a variable into a directive like this:

<SCRIPT LANGUAGE="JavaScript" type="text/javascript"
src="$myPageVar$"></SCRIPT>
....where $myPageVar$ is a variable I''ve declared, and somehow,
magically, its value gets put into this directive? The only way I can
get this to work is if I hard-code a value for $myPageVar$ in the
following way:

<SCRIPT LANGUAGE="JavaScript" type="text/javascript"
src="homeInc.js"></SCRIPT>
....which is of limited use. Is there a way for me to use variables in
such a directive? Or is there a better way to be doing client-side
includes?

Thanks.

解决方案

myPageVar


"></SCRIPT>
....where


myPageVar


这篇关于客户端包含JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆