使用JavaScript的静态和动态内容的href [英] a href with static and dynamic content using JavaScript

查看:66
本文介绍了使用JavaScript的静态和动态内容的href的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello all


我对网络开发很陌生,所以请善待;)


我有一个JS-函数叫做getObjURL(),它应该返回一个URL-

一个JS对象的字符串。


在正文部分我使用这样的东西:


< a href =" ../ mystaticlink.htm?parameter = javascript :getObjURL()"

target = " _blank" ...> Linktext< / a>


但这不起作用。

我也尝试过:

< a href =" ../ mystaticlink.htm?parameter =" + javascript :getObjURL()

target =" _blank"。 ..> Linktext< / a>

< a href =" ../ mystaticlink.htm?parameter =<%javascript :getObjURL()%> ;"

target =" _blank" ...> Linktext< / a>

....以及其他一些愚蠢的东西。


你能帮我解决这个问题吗?!它会不会工作,或者我用

来使用其他网络技术来创建我的动态链接?


祝你好运,

Schuessi

解决方案

10月29日,3:31 * pm,schuessi< schuessmas ... @ googlemail.comwrote:
< blockquote class =post_quotes>
你好所有


我对网络开发很新,所以请善待;)


我有一个名为getObjURL()的JS函数,它应该返回一个URL-

JS对象的字符串。


在正文部分我使用这样的东西:


< a href =" ../ mystaticlink.htm?parameter = javascript :getObjURL()"

target =" _blank" ...> Linktext< / a>


但这不起作用。

我也尝试过:

< a href =" ../ mystaticlink.htm?parameter =" + javascript :getObjURL()

target =" _blank" ...> Linktext< / a>

< a href =" ../ mystaticlink.htm?parameter =<%javascript :getObjURL()%>"

target =" _blank" ... > Linktext< / a>

...以及其他一些愚蠢的事情。


你能帮我解决这个问题吗?!它会不会工作,或者我用

来使用其他网络技术来创建我的动态链接?


祝你好运,

Schuessi



你好Schuessi。

尝试这个..


< script language = " JavaScript的" type =" text / javascript">

函数getParam(){

返回''first'';

}

函数getLink(){

document.getElementById(''link'')。href =''mystaticlink.htm?

parameter =''+ getParam();

}

< / script>

< a href ="#"的onclick = QUOT; getLink();" id =" link"> First< / a>


29 Okt。,11:48,Suhas Dhoke< suhasdh ... @ gmail.comwrote:


10月29日,3:31 * pm,schuessi< schuessmas ... @ googlemail.comwrote:


Hello all


我是网站开发的新手,所以请善待;)


我有一个名为getObjURL()的JS函数,它应该返回一个URL-

JS对象的字符串。


在正文部分我使用类似这样的东西:


< a href =" ../ mystaticlink.htm?parameter = javascript :getObjURL()"

target =" _blank" ...> Linktext< ; / A>


但这不起作用。

我也尝试过:

< a href =" ../ mystaticlink.htm?parameter =" + javascript :getObjURL()

target =" _blank" ...> Linktext< / a>

< a href =" ../ mystaticlink.htm?parameter =<%javascript :getObjURL()%>"

target =" _blank" ...> Linktext< / a>

......以及其他一些愚蠢的事情。


你能帮我解决这个问题吗?!它会不会工作,或者我用

来使用其他网络技术来创建我的动态链接?


祝你好运,

Schuessi



你好Schuessi 。

尝试这个..


< script language =" JavaScript" type =" text / javascript">

函数getParam(){

* *返回''first'';}


函数getLink(){

* * document.getElementById(''link'')。href =''mystaticlink.htm?

parameter =''+ getParam();}


< / script>

< a href ="#"的onclick = QUOT; getLink();" ID =&]连结">首先< / A>



这很好用,谢谢!


10月29日早上6点48分,Suhas Dhoke < suhasdh ... @ gmail.comwrote:


10月29日,3:31 * pm,schuessi< schuessmas ... @ googlemail.comwrote:


Hello all


我对网络开发很新,所以请成为kind;)


我有一个名为getObjURL()的JS函数,它应该返回一个URL-

字符串JS对象。


在正文部分我使用类似这样的东西:


< a href =" ../ mystaticlink.htm?parameter = javascript :getObjURL()"

target =" _blank" ...> Linktext< ; / A>


但这不起作用。

我也尝试过:

< a href =" ../ mystaticlink.htm?parameter =" + javascript :getObjURL()

target =" _blank" ...> Linktext< / a>

< a href =" ../ mystaticlink.htm?parameter =<%javascript :getObjURL()%>"

target =" _blank" ...> Linktext< / a>

......以及其他一些愚蠢的事情。


你能帮我解决这个问题吗?!它会不会工作,或者我用

来使用其他网络技术来创建我的动态链接?


祝你好运,

Schuessi



你好Schuessi 。

尝试这个..


< script language =" JavaScript"类型= QUOT;文本/ JavaScript的">



不要使用语言属性。


function getParam(){

* *返回''第一'';}


函数getLink(){

* * document.getElementById(''link'' ).href =''mystaticlink.htm?

参数=''+ getParam();}


< / script>

< a href ="#"的onclick = QUOT; getLink();" ID =&]连结">首先< / A>



荒谬且无法进入(无论它应该做什么。)


Hello all

I''m quite new to web development, so please be kind ;)

I have a JS-function called getObjURL() which should return an URL-
String of an JS-object.

In the body part I use something like this:

<a href="../mystaticlink.htm?parameter=javascript:getObjURL()"
target="_blank"...>Linktext</a>

but this doesn''t work.
I also tried:
<a href="../mystaticlink.htm?parameter="+javascript:getObjURL( )
target="_blank"...>Linktext</a>
<a href="../mystaticlink.htm?parameter=<%javascript:getObjURL( )%>"
target="_blank"...>Linktext</a>
.... and some other stupid things.

Could you please help me out of this?! Will it ever work or do I have
to use other web-technologies to create my dynamic link?

Best regards,
Schuessi

解决方案

On Oct 29, 3:31*pm, schuessi <schuessmas...@googlemail.comwrote:

Hello all

I''m quite new to web development, so please be kind ;)

I have a JS-function called getObjURL() which should return an URL-
String of an JS-object.

In the body part I use something like this:

<a href="../mystaticlink.htm?parameter=javascript:getObjURL()"
target="_blank"...>Linktext</a>

but this doesn''t work.
I also tried:
<a href="../mystaticlink.htm?parameter="+javascript:getObjURL( )
target="_blank"...>Linktext</a>
<a href="../mystaticlink.htm?parameter=<%javascript:getObjURL( )%>"
target="_blank"...>Linktext</a>
... and some other stupid things.

Could you please help me out of this?! Will it ever work or do I have
to use other web-technologies to create my dynamic link?

Best regards,
Schuessi

Hello Schuessi.
try this..

<script language="JavaScript" type="text/javascript">
function getParam() {
return ''first'';
}
function getLink() {
document.getElementById(''link'').href= ''mystaticlink.htm?
parameter='' + getParam();
}
</script>
<a href="#" onclick="getLink();" id="link">First</a>


On 29 Okt., 11:48, Suhas Dhoke <suhasdh...@gmail.comwrote:

On Oct 29, 3:31*pm, schuessi <schuessmas...@googlemail.comwrote:

Hello all

I''m quite new to web development, so please be kind ;)

I have a JS-function called getObjURL() which should return an URL-
String of an JS-object.

In the body part I use something like this:

<a href="../mystaticlink.htm?parameter=javascript:getObjURL()"
target="_blank"...>Linktext</a>

but this doesn''t work.
I also tried:
<a href="../mystaticlink.htm?parameter="+javascript:getObjURL( )
target="_blank"...>Linktext</a>
<a href="../mystaticlink.htm?parameter=<%javascript:getObjURL( )%>"
target="_blank"...>Linktext</a>
... and some other stupid things.

Could you please help me out of this?! Will it ever work or do I have
to use other web-technologies to create my dynamic link?

Best regards,
Schuessi


Hello Schuessi.
try this..

<script language="JavaScript" type="text/javascript">
function getParam() {
* * return ''first'';}

function getLink() {
* * document.getElementById(''link'').href= ''mystaticlink.htm?
parameter='' + getParam();}

</script>
<a href="#" onclick="getLink();" id="link">First</a>

This works great, thank you!


On Oct 29, 6:48*am, Suhas Dhoke <suhasdh...@gmail.comwrote:

On Oct 29, 3:31*pm, schuessi <schuessmas...@googlemail.comwrote:

Hello all

I''m quite new to web development, so please be kind ;)

I have a JS-function called getObjURL() which should return an URL-
String of an JS-object.

In the body part I use something like this:

<a href="../mystaticlink.htm?parameter=javascript:getObjURL()"
target="_blank"...>Linktext</a>

but this doesn''t work.
I also tried:
<a href="../mystaticlink.htm?parameter="+javascript:getObjURL( )
target="_blank"...>Linktext</a>
<a href="../mystaticlink.htm?parameter=<%javascript:getObjURL( )%>"
target="_blank"...>Linktext</a>
... and some other stupid things.

Could you please help me out of this?! Will it ever work or do I have
to use other web-technologies to create my dynamic link?

Best regards,
Schuessi


Hello Schuessi.
try this..

<script language="JavaScript" type="text/javascript">

Don''t use the language attribute.

function getParam() {
* * return ''first'';}

function getLink() {
* * document.getElementById(''link'').href= ''mystaticlink.htm?
parameter='' + getParam();}

</script>
<a href="#" onclick="getLink();" id="link">First</a>

Ridiculous and inaccessible (whatever it is supposed to do.)


这篇关于使用JavaScript的静态和动态内容的href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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