• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using document.location.href to create a link in function

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I built a link using

<a href='int/readI.do?inta=<bean:write name="inta" property="id"/>'>

Once rendered it filled in the http://www.domain.com/

displaying http://www.domain.com/int/readI.do?inta=123456

-------------------------------------------------------------------

I built another link where I passed in information to a function.

function used


html calling function

<a href="javascript:setSId('484919','N/A','int/readI.do?intid=1340387')"/>P388</a>

However when it throughs this link using document.location.href the link is missing

html://www.domain.com/

I know this because I contactenated that part and it worked.

What do I need to do to use document.location.href in order for it prefix in the domain.

Or is there another way I can call a function and after the function has run fire off the link

 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags in the future. They preserve formatting and make your code easier to read.
This has nothing to do with Struts. Javascript runs in the browser. I believe the browser completes relative URL's, so in your case you'll have to add the domain name.
I'll move this to a more appropriate forum.
 
author
Posts: 297
5
Android Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or you could just use the a as intended, put the link as the href and set your cookie in the click event.
 
author
Posts: 20
5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

howard franklin wrote:



Keep JavaScript out of your HTML, and HTML out of your JavaScript. If you're using jQuery, you can do this:


 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Elliott wrote:Keep JavaScript out of your HTML, and HTML out of your JavaScript.


Print this out in a 144 point font. Hang it on your wall where you can clearly see it from your computer desk.

I'd say have it tattooed on your forehead, but who looks in a mirror while they're coding?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic