Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

java function in link 1

Status
Not open for further replies.

jrobertblack

Technical User
Joined
Feb 12, 2006
Messages
5
Location
US
Post subject: java function in link

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

How can i link to a page and perform a java script function at the same time.

I have to link to a page like this- ..../AgentHome/Homepage.aspx

and perform this java on that page - javascript:SubmitAgentListings('AllMyListings');

its actually a button on that page the full link is this - <a href="javascript:SubmitAgentListings('AllMyListings');" class="buttontext" name="AgentSearchType"><b>ALL MY LISTINGS</b></a>

I need to link to that page - cant do a direct link because it changes , and I am framing the content. Real estate person what to show her listing from her main site framed in teh new site
 
Do you have access to modify the page you are linking to?
You cannot directly execute the code on a different page but you can pass a parameter to that page and when the page loads if the value was passed then you execute the function.

I assume you build the link dynamically to accomodate the changes in the href? When you build the link just append a parameter to it like "?myscript=1"
So your link looks like:
<a href="/AgentHome/Homepage.aspx?myscript=1" class="buttontext" name="AgentSearchType">

And in your Homepage.aspx file you would retrieve the value of myscript and use it to conditionally trigger the javascript function when the page loads.





Stamp out, eliminate and abolish redundancy!
 
I have this real estate client, and she picked not to pay for a custom app to bring in all of her listings in from the database and to the new site

So we framing her listings page into the new site, the problem is that the page we are framing is always changing and dies when the database updates.

So I thought we could link to the page right before that doesnt change and perform the button action to go to the listings.
The old site we are linking to at the bottom is a yellow button called "ALL MY LISTINGS", the page it brings up with all the houses is the page Im trying to frame on the new site.


this is what I am using

<iframe name="content" id="content" src=" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>


I cannot change anything on the page I am framing
 
You could alter the link to this:

This will pass a value to the new page on the querystring.
In the code for Hopepage.aspx you use something like this:
Redirection = Request.QueryString('myval')

Then have an onload event in the page like this.

<body onload="if (<%=Redirection%> == 1) { SubmitAgentListings('AllMyListings'); }">

The idea is to pass in a value to the page that acts as an indicator as to whether it should execute the function or not. Then in the onload event test the value and if it passes then execute the function listed. This has to happen after the page has completed loading which is why I put it into the onload event.



Stamp out, eliminate and abolish redundancy!
 
ok let me clarify I think im doing something wrong here


this is what I have in my iframe -

<iframe name="content" id="content" src=" Redirection = Request.QueryString('myval') width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>

then on the same page right after the head i put -

<body onload="if (<%=Redirection%> == 1) { SubmitAgentListings('AllMyListings'); }">

what am I doing wrong
 
Redirection = Request.QueryString('myval')
and
<body onload="if (<%=Redirection%> == 1) { SubmitAgentListings('AllMyListings'); }">
have to go into the Homepage.aspx page.

When that page loads it reads the querystring for the parameter myval and stores it in the variable Redirection.
That line is ASP so has to be in the ASP code tags of the page.

Then the onload function is taking the ASP variable Redirection and using it inside a Javascript if statement and if it has the value 1 it executes the javascript function SubmitAgentListings which I assume is already a function on the Homepage.aspx page?

Stamp out, eliminate and abolish redundancy!
 
we cant change anything on the asp page its belong to the whole real estate agency and we are working with just one of the agents on her personal site.

The page changes every so often so we cant link to that page - is there any way to link directly to that page?
 
So, you have a client who doesn't want to pay the money to do things the RIGHT way, but she's willing to pay you to fix the kludge every so often and put up with a website that not only doesn't work, but ends up looking unprofessional?

Lee
 
ya the listing are in an idx database and would have to be pulled out and would have to be custom built. None of the premade real estate scripts would work on it. My knowledge doesnt cover that as my specialty is flash and actionscript, so I would have to outsource that and quotes I got were around 3 hundred and she didnt want to pay the extra. If I could do it I would, and not even charge her jsut because it would look a lot better. But right now im just trying to get this to work without having to change the link every so often
 
quotes I got were around 3 hundred and she didnt want to pay

USD $300 would be between 5 and 8 hours work for most professional web developers - which is probably now longer than you have spent on it, I'm guessing.

People get what they pay for - maybe she needs to be reminded of this?

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
If the other page cannot be modified directly and it is on a different domain than her pages then I do not think there is anything you can do to execute the code.
This falls under the category of cross site scripting which is a major security issue and is locked down by the browser.


Stamp out, eliminate and abolish redundancy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top