Forum Moderators: open

Message Too Old, No Replies

How to rip off the href part?

need to take that off to pass the url as a parameter

         

Majinboo

8:18 pm on Sep 30, 2004 (gmt 0)

10+ Year Member



Hello,

How do I rip-off the

a href=""
part from a link so I can pass the URL as a parameter to an opener?

I need to open the target links from a child window on it's opener so I came out with this:

function go(url){ 
window.opener.location.href = url;
}

And to call it:

onClick="go();return false" 
which would be like :
 onClick="go(someURL.htm);return false" 

The whole thing is a child window which holds a search form and consequent results that should that as one click, opens the target on the parent.

Also, do I have to use a function to reset the parent to

onUnload=null
or thats not necessary? (I'm new to JS and got that code pieces on a site that uses the resetting).

I apreciate any help, thanks

StupidScript

8:33 pm on Sep 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not exactly sure what you are asking, as you can write the code any way you like, search result or not.

Can you use:

<a href="javascript:void(go('somepage.htm'))">SomePage</a>

?

(Use of the "void" operator suppresses any returned value, similar to "return false")

Bernard Marx

8:55 pm on Sep 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you mean that you have a link like this in the child:

<a href="blah.htm">

Then this should do it:

<a href="blah.htm" onclick="go(this.href);return false;">

I'm not sure how you'd get into this situation in the first place though. (?)

Majinboo

4:54 am on Oct 1, 2004 (gmt 0)

10+ Year Member



I'm not sure how you'd get into this situation in the first place though. (?)

That child window is, first, a search form then its results. Its powered by Atomz and they use proprietary tags to build the templates. In this case,

<SEARCH-LINK> ... </SEARCH-LINK>
is used several times to parse each one of the target links resulted from the search.

And yes, the

<a href="blah.htm" onclick="go(this.href);return false;">
code will do (goes into the
<SEARCH-LINK>
) but... now that I can open the link from child on parent, it's working only for the first link (remember? the links from search that shows on child) anything after that will open on the child, not more on parent.

Would that have something to do with that

onUnload=null
on the first post?

P.S. - I have ask you to be kind with my english, sorry, I know it's not very concise nor very clear but it's not my language. Portuguese if you are wondering... :)

StupidScript

4:28 pm on Oct 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<a href="blah.htm" onclick="go(this.href);return false;">

If the go() function is as you originally posted, I don't see any reason why the opener.location.href would not be changed with any link coded like that in the child. Should work for all links with that code.

Works fine in a test I just did.

Would you post a bit of the search result code so we can see what you have to work with?

Majinboo

7:03 am on Oct 2, 2004 (gmt 0)

10+ Year Member



I'll check it tomorrow (sat) afternoon (about 3 am here right now)