Forum Moderators: open

Message Too Old, No Replies

JavaScript solution needed to prevent page from refreshing

In need of code to maintain place on page after opening new window

         

eveolasov

11:40 pm on Jan 18, 2004 (gmt 0)

10+ Year Member



I'm in a quandary but believe there's a simple java script solution using the OnClick.

I need to find some simple solution so that once a visitor clicks on one of the mls listing numbers which displays a new window with the full listing - they return to the same place in the master list rather than have the page refresh to the top of the list which it's currently doing. I'm sure this is driving my visitors crazy!

Anyone have the solution?

Purple Martin

12:11 am on Jan 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could open the page at a named anchor.

tedster

1:09 am on Jan 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



a visitor clicks on one of the mls listing numbers which displays a new window with the full listing

Given that fact, I don't understand why the original window refreshs when it regains focus, unless you already have a script on the original page that's generating that specific behavior.

Rather than fight against it, doesn't it make more sense to find the cause of the refresh behavior and eliminate it.

Or perhaps I misunderstand, and the full listing appears as a new document, but loaded in the SAME window? Even then, I think the Back Button normally returns to the identical spot in the document previously loaded.

eveolasov

1:37 am on Jan 19, 2004 (gmt 0)

10+ Year Member



My page consists of multiple tables with 100's of links to individual mls listings which are opened in smaller resizable windows which when x'd out of leaves the main listings page but instead of returning to the place on the page the viewer just left - it's refreshed to top of page.

The content (tables) aren't written by me but are generated by our mls system. I copy and paste the updated contents as necessary updates to each page. I've looked at their script and it's rather messy indeed since auto generated by my queries.

<a href="#" onClick=javascript:window.open*
('http://www.example.com/CharlestonReports/ListitLib/report_builder.aspx?*
report=public_full_prop1_con&footer=57505157&mls_acct=12210048','RptWin',*
'left=1,top=1,width=750,height=550,toolbar=0,location=0,directories=0,*
resizable=1,status=0,menubar=1,scrollbars=1');return false;">2210048</a>

* line breaks added to prevent side-scroll

Nothing above references my website by the way.
If I could employ a (find and replace) to remove the culprit and still have my page work - I'd be grateful.

Ideas? I'm creative but NOT a webmaster. I'm thrilled to say my sites (after months of reworking) are back in the top 10 since Google blasted me with Florida! I done good.....

Hopefully I'll solve this irritating problem. Folks hate losing their place when dealing with lists of 100's of real estate listings.

I just really looked at the above script - is the return false the culprit? What should it be?
true? I need a pro.....

[edited by: tedster at 6:58 am (utc) on Jan. 19, 2004]

Purple Martin

2:10 am on Jan 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We might be able to put some JavaScript in the new page which makes use of the parameter &mls_acct=12210048 in the URL. Are you able to put some JavaScript in both the original and new page?

TrinkDawg

2:10 am on Jan 19, 2004 (gmt 0)

10+ Year Member



Hi, I just tried the link you posted, and there was one thing I noticed - you are missing a " at the beginning of your onClick. It should read

<a href="#" onClick="javascript:window.open

When I added that it worked fine. Without it I think the return false is not getting executed so the link to "#" will execute, which takes you to the top of the page.

Hope that helps.

eveolasov

2:24 am on Jan 19, 2004 (gmt 0)

10+ Year Member



Thank you TrinkDawg!
I just did a find and replace and added the "
to the javascript and BINGO - I'm returned to my place on the page.

This is simple and just one more step to make my pages work in my update process. My visitors will be happier I'm sure.

"C'es La Vie" in the world of code - one small error makes for BIG problems.

THANKS.........

Saintjude

2:52 am on Jan 19, 2004 (gmt 0)



Hi, people,

There is a simpler solution to your problem. You don't actually need the javascript: protocol part in your onClick handler, in fact I'd go as far as saying it shouldn't even be there at all. You can ditch it, and the href="#".

The javascript protocol and the rest of the code is a kind of dummy 'address', and, on the page, is (perhaps I should say was) used only in an href attribute. There's really no need for it in today's browsers.

It's late at night, and I'm getting paranoid about whether every one of the above statements is correct. So here's a link to a similar discussion.

[faqts.com ]