Set window size when browser opens? (and why is the thread below locked?)
May 29, 2013 12:00 AM
Two questions:
1) If it is possible, how can you set the size of the browser window that opens when you launch a Lectora e-learning?
2) What does it mean when a thread on this forum is "locked" ? Another user posted the same question a few days ago, but the thread was locked before anyone answered.
Discussion (10)
top.window.moveTo(0,0);
top.window.resizeTo(screen.width,screen.height);
basically what it does is tell the "parent of all windows" to move itself so that the x,y of the window is at the top left of the screen. the it tells the browser to resize itself to fill the computer screen.
you have to add this as an external html element and set it to top of file so it runs before anything else.
@peterLEXsorenson 50746 wrote:
Pixel: ( great handle by the way )
It would be more helpful to just tell me what you want to do rather than provide me with code that isn't working.
Basically what you want to do is take the width of the window that you want and subtract that from the screen size, the divide that in half and then use that to set the x position of the window.
So let's say you're at 1024 x 768 and you have a browser target width of 700.
setMePage(700);
function setMePage(myBW){
var toAdd = ((screen.width-myBW)/2);//or 1024-700 = 324/2 = 162
top.window.moveTo(toAdd ,0);//162x,0y
top.window.resizeTo(myBW,screen.height);//or whatever height you want the browser to be
}
Granted I didn't test this - but you can test it and tell me if it works. If not I'll correct it.
Hi Peter,
Very interesting and thanks for sharing. I'm not a JS person but would think that this would execute on every page of a WBT. Is there a chance that running this on every page, there could be potential issues like a memory leak?
Thanks,
kelly
ps. We met a few years ago at a Lectora conference
@peterLEXsorenson 56235 wrote:
A memory leak is not an issue here - and yes it would execute on every page so you put it at the root of the course.
Actually - what we do now - in LiMS ( CHRONNICLE ) is execute it in the ondocumentready function of jQuery so it runs before the page is presented to the the browser.
It's not constantly running. Once it runs it quits - so if the user resized the browser window it wouldn't "re-run" the script.
It's a dumb script - executes once and that's it ( even though it IS once per page ).
I know you - your company hasn't elected to join the LiMS/CHRONNICLE users yet.... ;-)
Hi Peter,
So what about using a css instead like this:
I'm trying to figure out the pros and cons for doing the js or the css route.
As always, I value your opinion.
-kelly
@LimeandNavy 50711 wrote:
Two questions:
1) If it is possible, how can you set the size of the browser window that opens when you launch a Lectora e-learning?
2) What does it mean when a thread on this forum is "locked" ? Another user posted the same question a few days ago, but the thread was locked before anyone answered.
If your using Publisher I can send you the code that works for us but if you're using Inspire we are looking for the same code.
With our courses built in Lectora Professional Publisher, we were able to control the size of the browser window. It was being resized by the LMS but we found code that worked. This code works with Publisher but when we try to use it with Inspire the browser window is double the length. So has anyone found code that works with Inspire?
I also wondered why the thread was locked. Still hoping for an answer to this question! I suspect that the browser window size is a function of the LMS, and may not be adjustable in Lectora itself. I haven't been able to find any settings in Lectora, but, maybe someone out there knows the trick of it?
@peterLEXsorenson 50725 wrote:
top.window.moveTo(0,0);top.window.resizeTo(screen.width,screen.height);
basically what it does is tell the "parent of all windows" to move itself so that the x,y of the window is at the top left of the screen. the it tells the browser to resize itself to fill the computer screen.
you have to add this as an external html element and set it to top of file so it runs before anything else.
Thanks Peter, I'm trying to define a browser window size instead of filling up the computer screen and having issues with that. I did have this, that worked with Publisher, but with Inspire the browser window is twice the height it should be. Do you have any suggestions?
Pixel: ( great handle by the way )
It would be more helpful to just tell me what you want to do rather than provide me with code that isn't working.
Basically what you want to do is take the width of the window that you want and subtract that from the screen size, the divide that in half and then use that to set the x position of the window.
So let's say you're at 1024 x 768 and you have a browser target width of 700.
setMePage(700);
function setMePage(myBW){
var toAdd = ((screen.width-myBW)/2);//or 1024-700 = 324/2 = 162
top.window.moveTo(toAdd ,0);//162x,0y
top.window.resizeTo(myBW,screen.height);//or whatever height you want the browser to be
}
Granted I didn't test this - but you can test it and tell me if it works. If not I'll correct it.
@peterLEXsorenson 50746 wrote:
Pixel: ( great handle by the way )
It would be more helpful to just tell me what you want to do rather than provide me with code that isn't working.
Basically what you want to do is take the width of the window that you want and subtract that from the screen size, the divide that in half and then use that to set the x position of the window.
So let's say you're at 1024 x 768 and you have a browser target width of 700.
setMePage(700);
function setMePage(myBW){
var toAdd = ((screen.width-myBW)/2);//or 1024-700 = 324/2 = 162
top.window.moveTo(toAdd ,0);//162x,0y
top.window.resizeTo(myBW,screen.height);//or whatever height you want the browser to be
}
Granted I didn't test this - but you can test it and tell me if it works. If not I'll correct it.
Thank you! You are a genius! And thank you for the explanation, helped me understand the code so I was able to tweak the numbers to get the browser window size I needed.
A memory leak is not an issue here - and yes it would execute on every page so you put it at the root of the course.
Actually - what we do now - in LiMS ( CHRONNICLE ) is execute it in the ondocumentready function of jQuery so it runs before the page is presented to the the browser.
It's not constantly running. Once it runs it quits - so if the user resized the browser window it wouldn't "re-run" the script.
It's a dumb script - executes once and that's it ( even though it IS once per page ).
I know you - your company hasn't elected to join the LiMS/CHRONNICLE users yet.... ;-)
Discussions have been disabled for this post