Solved

passing a variable to ahref?

Posted on 1998-10-05
5
187 Views
Last Modified: 2010-04-09
I need to have a hyperlink that can be passed a variable which is the result of a javascript that runs when the page is loaded. The link will point to a .gif who's name is dependent on the current date. How can I pass the result of my javascript function to href= so that the link will dynamically update itself?
0
Comment
Question by:rizzok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
nchalasa062698 earned 50 total points
ID: 1838366
At the hyper link call the javascript function and that function can do
   window.location.href="the new url".

and syntax for that hyperlink is,
    <A HREF="javascript:function_name()">text_to_display</A>
0
 

Author Comment

by:rizzok
ID: 1838367
That's what I had in mind but can I pass a variable to where it says "the new url".

you wrote:

At the hyper link call the javascript function and that function can do window.location.href="the new url".  

0
 
LVL 1

Expert Comment

by:nchalasa062698
ID: 1838368
yes , you can.

If you tell me exactly what you want to do , I can write
 the code more clearly.
0
 

Author Comment

by:rizzok
ID: 1838369
My function will result in a variable that contains a filename that changes every Friday at midnight and it's name is made up of the date (eg. 981002.gif).

So, window.location.href="var1" will work, being that var1 (=981002.gif) is the result of my function? With or without ""?
This is all the info I need, then the points are yours!!

0
 
LVL 1

Expert Comment

by:nchalasa062698
ID: 1838370
window.location.href=var1 ( without the codes should work for you.)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mobile apps - web/native or hybrid? 1 120
links not working 2 34
TypeError jquery issues with site - CSS conflicts 3 46
Table style position to the left 8 39
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question