Internet Advertising - Debt Consolidation - Debt Consolidation - Travel news - Indian television shows news

PDA

View Full Version : ScrollTo() SetTimeout() Postioning Popup??


brianj
Apr 26th 2009, 1:02 am
Hi everyone..

i know Popups are a bad thing, but for my personal desktop i'm trying to create a popup that scrolls a page (news site etc.) down to a fixed position:

//simple popup that works
<a href="javascript:void(0);"
onClick="window.open('http://site.com/news',
'popup', 'location=no, menubar=no, scrollbars=0,
status=no, resizable=no, width=400, height=300');
">Open Popup</a>

//???
window.scrollTo(350, 0);
window.setTimeout ( ??? )


Does anyone know how to apply the SetTimeout() to make the scroll actually work?

Thanks for help!

brianj
Apr 26th 2009, 10:35 pm
any chance at all?

JavaScriptBank.com
Apr 27th 2009, 11:22 pm
you must place you code into a function, then use setTimeout method to execute

setTimeout Method


Syntax

iTimerID = window.setTimeout( vCode , iMilliSeconds [ , sLanguage ] )


Evaluates an expression after a specified number of milliseconds has elapsed.

Return Value

Integer. Returns an identifier that cancels the evaluation with the clearTimeout method.


hope this is useful

camjohnson95
Apr 29th 2009, 3:41 am
something like this will work:

<a href="javascript:openWindow();" >Open Popup</a>
<script type="text/javascript">
var myPopup;
function openWindow() {
myPopup = window.open("mynews.html", 'popup', 'location=no, menubar=no, scrollbars=yes, status=no, resizable=no, width=400, height=300')
setTimeout("myPopup.scrollTo(0, 350);", 2000);
}
</script>

But... Most (if not all) browsers will only allow javascript to scroll the contents of a popup IF the page that is loaded is from the same host as the page that has created the popup.
I'm not sure if there is a way around this, maybe loading a local file that has a frame containing the intented target, and then scrolling it from there... But it may not even allow that.

dimitar christoff
May 1st 2009, 4:11 am
set id="anchor" and the source as mynews.html#anchor, may work w/o anything too fancy.