HighDots Forums  

.js include creates extra line in html display

Javascript JavaScript language (comp.lang.javascript)


Discuss .js include creates extra line in html display in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tobierre
 
Posts: n/a

Default .js include creates extra line in html display - 10-04-2005 , 03:21 AM






Hi All,

In a web page I have created I have included a .js file in the body section
of the page with the below JavaScript code. The code works fine, but
creates an extrra blank line at the bottom of the web page! Does anyone
know why this is happening?

Any help kindly appreciated

Tobierre

Code:
document.write('<img width="1" height="1" src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' + screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth + '">\n');



Reply With Quote
  #2  
Old   
Baconbutty
 
Posts: n/a

Default Re: .js include creates extra line in html display - 10-04-2005 , 03:40 AM






Quote:
'">\n');
\n is a Javascript escape value for a new line



Reply With Quote
  #3  
Old   
Spartanicus
 
Posts: n/a

Default Re: .js include creates extra line in html display - 10-04-2005 , 04:09 AM



"Tobierre" <No-Reply (AT) hotmail (DOT) com> wrote:

Quote:
In a web page I have created I have included a .js file in the body section
of the page with the below JavaScript code. The code works fine, but
creates an extrra blank line at the bottom of the web page! Does anyone
know why this is happening?

Any help kindly appreciated

Tobierre

Code:
document.write('<img width="1" height="1" src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' + screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth + '">\n');
Remove the "\n" at the end of the code.

--
Spartanicus


Reply With Quote
  #4  
Old   
Tobierre
 
Posts: n/a

Default Re: .js include creates extra line in html display - 10-04-2005 , 04:32 AM



Hi Spartanicus,

Yes \n is a newline in the code but it only represents "white space" in html
and is not equal to <br> so should not visibly display a new line in the
browser.

Also I have removed the \n from the code with no change to the display...

Tobierre



----- Original Message -----
From: "Spartanicus" <invalid (AT) invalid (DOT) invalid>
Newsgroups: comp.lang.javascript
Sent: Tuesday, October 04, 2005 9:09 AM
Subject: Re: .js include creates extra line in html display


Quote:
"Tobierre" <No-Reply (AT) hotmail (DOT) com> wrote:

In a web page I have created I have included a .js file in the body
section
of the page with the below JavaScript code. The code works fine, but
creates an extrra blank line at the bottom of the web page! Does anyone
know why this is happening?

Any help kindly appreciated

Tobierre

Code:
document.write('<img width="1" height="1" src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' + screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth + '">\n');

Remove the "\n" at the end of the code.

--
Spartanicus
"Spartanicus" <invalid (AT) invalid (DOT) invalid> wrote

Quote:
"Tobierre" <No-Reply (AT) hotmail (DOT) com> wrote:

In a web page I have created I have included a .js file in the body
section
of the page with the below JavaScript code. The code works fine, but
creates an extrra blank line at the bottom of the web page! Does anyone
know why this is happening?

Any help kindly appreciated

Tobierre

Code:
document.write('<img width="1" height="1" src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' + screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth + '">\n');

Remove the "\n" at the end of the code.

--
Spartanicus



Reply With Quote
  #5  
Old   
twaddle
 
Posts: n/a

Default Re: .js include creates extra line in html display - 10-04-2005 , 05:29 AM



Quote:
The code works fine, but creates an extrra blank line at
the bottom of the web page!

Quote:
document.write('<img width="1" height="1"
src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' +
screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth +
'">\n');
I'm guessing a HTML image would also create that space (because of
line-height). If so, do this:

CSS:
..script img { display: block }

HTML:
<div class="script">
<script type="text/javascript">
// Your code
</script>
</div>



Reply With Quote
  #6  
Old   
Tobierre
 
Posts: n/a

Default Re: .js include creates extra line in html display - 10-04-2005 , 08:21 AM



Thanks Twaddle,

Your suggestion makes sense, I missed that one! I altered your css as
follows:

<span style="display: none;">
<script src="filepath"></script>
</span>

Thanks Tobierre

"twaddle" <twaddle (AT) gmail (DOT) com> wrote

Quote:
The code works fine, but creates an extrra blank line at
the bottom of the web page!


document.write('<img width="1" height="1"
src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' +
screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth
+
'">\n');

I'm guessing a HTML image would also create that space (because of
line-height). If so, do this:

CSS:
.script img { display: block }

HTML:
div class="script"
script type="text/javascript"
// Your code
/script
/div




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.