a href with static and dynamic content using JavaScript

S

schuessi

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
 
S

Suhas Dhoke

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>
 
S

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!
 
D

David Mark

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.)
 
D

David Mark

This works great, thank you!

No it doesn't. You have been advised to do something stupid. Agents
without script or with script disabled will feature a link that does
nothing.

If you can explain just what it is you are trying to do, perhaps you
will get some competent advice.
 
D

David Mark

Hello all

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

If you are new to Web development, then why are you trying to write
scripted enhancements. You should concentrate on creating proper
static documents first. Worry about scripting later.
I have a JS-function called getObjURL() which should return an URL-
String of an JS-object.

A what of a what? This is what I am talking about. You are jumping
in with both feet before you know what you are getting into.
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.

Which is hardly surprising. What made you think it would?
I also tried:
<a href="../mystaticlink.htm?parameter="+javascript:getObjURL()
target="_blank"...>Linktext</a>

Programming by trial and error is not recommended.
<a href="../mystaticlink.htm?parameter=<%javascript:getObjURL()%>"

You are officially lost.
target="_blank"...>Linktext</a>
... and some other stupid things.

Why are you wasting time with stupid things? Have you tried reading
about the subject?
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?

I haven't the slightest idea what you are trying to do here.
 
S

sasuke

If you are new to Web development, then why are you trying to write
scripted enhancements. You should concentrate on creating proper
static documents first. Worry about scripting later.




A what of a what? This is what I am talking about. You are jumping
in with both feet before you know what you are getting into.






Which is hardly surprising. What made you think it would?


Programming by trial and error is not recommended.


You are officially lost.


Why are you wasting time with stupid things? Have you tried reading
about the subject?




I haven't the slightest idea what you are trying to do here.

I wonder if we will get any reply on this one taking into
consideration that the OP just uttered the magic words; *it
works*. :)

../sasuke
 
G

Gregor Kofler

sasuke meinte:
I wonder if we will get any reply on this one taking into
consideration that the OP just uttered the magic words; *it
works*. :)

Another webpage atrocity meets the public. And I suppose the "solution"
gets copied thousands of times.

Gregor
 
D

David Mark

sasuke meinte:



Another webpage atrocity meets the public. And I suppose the "solution"
gets copied thousands of times.

Of course. I wonder what the blind community thinks of the Web. A
useless compendium of random gibberish? Google's excuse is they
"can't please everyone." It should be illegal (and is in some
countries, IIRC.) Perhaps that is the only way to take Website
development out of the hands of incompetents.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top