Blank page...?

DecemberGuild

New Member
Messages
107
Reaction score
0
Points
0
I'm using a script that doesn't seem to be working how I want it to.
I need the script to check the size of the scrollbars based on a DIV element on the page, and then return the size (this script is not mine).
I added another script to combine that with a CSS tag so that the script will parse the proper CSS tag based on the scrollbar width on the page.

I'm getting a problem. When I run the first script, which tests the DIV's scrollbar width, it erases the pages and replaces it with its results. So, instead of seeing the new CSS tag added near the top of my page, I'm seeing a page with nothing on it except that CSS tag.

Here is my page: [link]

Here is the script:
<script>
function getScrollerWidth() {
var scr = null;
var inn = null;
var wNoScroll = 0;
var wScroll = 0;
// Outer scrolling div
scr = document.createElement('div');
scr.style.position = 'absolute';
scr.style.top = '-1000px';
scr.style.left = '-1000px';
scr.style.width = '100px';
scr.style.height = '50px';
// Start with no scrollbar
scr.style.overflow = 'hidden';
// Inner content div
inn = document.createElement('div');
inn.style.width = '100%';
inn.style.height = '200px';
// Put the inner div in the scrolling div
scr.appendChild(inn);
// Append the scrolling div to the doc
document.body.appendChild(scr);
// Width of the inner div sans scrollbar
wNoScroll = inn.offsetWidth;
// Add the scrollbar
scr.style.overflow = 'scroll';
// Width of the inner div width scrollbar
wScroll = inn.offsetWidth;
// Remove the scrolling div from the doc
document.body.removeChild(
document.body.lastChild);
// Pixel width of the scroller
return (wNoScroll - wScroll);
}
</script>
<script>
function stylescroll() {
document.write("<style>#footerContainer { padding-right:" + getScrollerWidth() + "px; }</style>");
}
window.onload = stylescroll;
</script>

Here is the outcome of the script:
<style>#footerContainer { padding-right:17px; }</style>

I sincerely thank you for any and all help.
 
Last edited:

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
It looks like there are two sets of "<html><body>" and "</body></html>" tags on that page. Maybe that is the problem?
 
Last edited:

mattyranks

New Member
Messages
156
Reaction score
0
Points
0
1. there is an extra <html> tag in the middle of the page

2. There are two <head></head> sections
 

DecemberGuild

New Member
Messages
107
Reaction score
0
Points
0
I know this. It works as is.
This is happening because I am using PHP to set frames, and the page is being included with its HTML, HEAD and BODY tags.

This is not the problem. The problem is the script, and I'm sure of it.


Edit: I don't think you're seeing what happens. When the page is maximized, it blanks out to white.
 
Last edited:

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
"document.body.removeChild(document.body.lastChild);"

If there are two body tags in the DOM, wouldn't that cause a problem? I may be wrong but.. If it's still not working, it's worth a try to remove one of them, in my opinion.
 

DecemberGuild

New Member
Messages
107
Reaction score
0
Points
0
Well, that may be it. I didn't even realize that.
But I'm going to use a different method. This method delays the page load a bit and doesn't work as I wanted it to.
 

aking47

New Member
Messages
13
Reaction score
0
Points
0
Even though you've decided not to use this... You can't use document.write after a page has loaded. use document.createElement or document.createTextNode if you want to add something to a page after it has loaded.
 
Top