homepage Welcome to WebmasterWorld Guest from 54.166.122.65
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Position browser in page
Jonesy

5+ Year Member



 
Msg#: 4366747 posted 4:52 pm on Sep 24, 2011 (gmt 0)

This may not be a PHP question, per se..
(Probably it's just a boneheaded question... )

My PHP script is reading a stands-on-its-own HTML page to change
certain text strings therein and push it out to the browser.

What I would like to do is position the browser within the page
ala a named anchor.

Is that even do-able?

Thanks, Jonesy.

 

penders

WebmasterWorld Senior Member penders us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



 
Msg#: 4366747 posted 5:31 pm on Sep 24, 2011 (gmt 0)

What I would like to do is position the browser within the page


? <=> Position the page within the browser?

You are changing the content of the page already, so you could add inline style as well I guess to position a page element? Is it just this one page?

Jonesy

5+ Year Member



 
Msg#: 4366747 posted 8:08 pm on Sep 24, 2011 (gmt 0)

What I want to do is position the browser window to a specific
location in the page as you would with an HTML#named_anchor request.

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4366747 posted 4:37 pm on Sep 26, 2011 (gmt 0)

So you're opening a new window and want it to position where you click?

If that's the case, the first thing to do is return false on the link,

<a href="my_new_window_function(); return false;">

But that's not really the best way to do it. You might be better served by having a hidden element,

#answer-object { display: none; }

<p><a href="some-link" onclick="return myFunction();">blah</a></p>
<p id="answer-object"></p>

Then on click of the link, write to the page using the <p> as a container, set the object's position and z-index relative to "wherever it is now," and make it visible by setting it's display to block.

This would be Javascript, but not even sure if that's the right answer . . .

Readie

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4366747 posted 12:13 am on Sep 28, 2011 (gmt 0)

You can move the window's position through jQuery's scrollTop function [api.jquery.com...]

(function($) {
$(window).ready(function() {
$(window).scrollTop(500); // Set the browser to be 500 pixels down the page
});
})(jQuery);

But I wouldn't be surprised if IE doesn't like that.

penders

WebmasterWorld Senior Member penders us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



 
Msg#: 4366747 posted 9:15 am on Sep 28, 2011 (gmt 0)

Or, to position the page at an element with id="MYID" then you could use JavaScript's own, non-standard, but universally accepted
scrollIntoView() method. Works in IE 6-8 (and above I assume), and all the rest.

document.getElementById('MYID').scrollIntoView();


These are all JavaScript solutions - as they will need to be I guess - nothing to do with PHP (but by the sounds of it you would be writing out the JavaScript with PHP I guess?)

omoutop

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4366747 posted 10:14 am on Sep 28, 2011 (gmt 0)

perhaps instead of moving the window into certain position (example <div id="myPos"></div>), you can remove/delete all content except that div, and just show that?

A certain knowledge of regular expressions is needed of course, for that approach.

Readie

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4366747 posted 5:37 pm on Sep 28, 2011 (gmt 0)

A certain knowledge of regular expressions is needed of course, for that approach.

I'm a great advocator of jQuery :)

$('body').find('*[id!=IdOfElementToShow]').hide();

Jonesy

5+ Year Member



 
Msg#: 4366747 posted 4:41 pm on Oct 1, 2011 (gmt 0)

I'd just as soon stay away from javascript (and jQuery).
What omoutop said about pruning all content preceding the
point where I want to (re)position is the way I'll go.

What I am trying to do is reposition on a form with one or
more fields in error -- a form that is near the bottom of
a page that is (probably) larger than than some browser windows.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved