GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Jack Up Browser Viewport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Jack Up Browser Viewport" Watch "Jack Up Browser Viewport" New topic
Author

Jack Up Browser Viewport

Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi All,

Good Day!
I would like to ask advise from the gurus here regarding what I want to do.

I basically have this HTML Markup, my form below has so many inputs and what the browser does is to
create a scrollbar when I am at the bottom of the page.


My problem is in my Jquery code. On click of the proceed button and a successful json response was generated.
I switch the focus into my info-div and change some message.


My problem is, I am still at the bottom of my browser viewport. I wanted my browser viewport to be at the top so that
user would see the animation.

Is there a way to do this? The .focus() function of jquery seems to not put my viewport back to the top.


Sean Clark ---> I love this place!!!
Me ------> I definitely love this place!!!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Isn't there a moveTo or scroll function or something? Have you considered searching the web?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

mark reyes wrote:Is there a way to do this? The .focus() function of jquery seems to not put my viewport back to the top.

That's right -- .focus() assigns a focus handler. So why don't you just use the element's focus method? Why over-complicate things?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

Set focus to first enabled input:
Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Set focus to first enabled input:


Hi Bear, I tried doing this. While it does set the focus at the first enabled input and jackup the browser a little, my info-div is still hidden as there is still an image in between them.

Isn't there a moveTo or scroll function or something? Have you considered searching the web?


Hi David, I actually played around with this code. I use the scrollTop value but it doesnt jackup the page. I am not sure if this has something to do
with the div initially not displayed so that's why the scrollTop function does not work. Or I could be wrong also..


I tried searching around the net and found this solution. I am not sure if this is elegant but it does do what I wanted, tested it in IE6 and Firefox.



Thanks.
 
GeeCON Prague 2014
 
subject: Jack Up Browser Viewport