简体   繁体   中英

How to center the page in popup after open bookmarklet?

javascript:q=location.href;p=document.title;void(open('http://example.page/links/bookmarklet_new?
link%5Burl%5D='+encodeURIComponent(q)+'&link%5Btitle%5D='+encodeURIComponent(p),'Page','toolbar=no,width=700,height=350'));

Im using Bookmarklet script like above. But in case if user is not logged he is redirected to root_path. But then I would like to scroll or center page to login form. I tried override styles. But how to check when page is open in popup window?

Have your bookmarklet add a query string parameter like &view=popup , then the page you open can check the query parameter and change the HTML or CSS as necessary. If your page redirects, make sure it checks for the view parameter and passes it to the next page.

Another option for showing the correct part of the page within the window is to use a hash and a fragment identifier in the url. For example #loginform .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM