By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

.js include creates extra line in html display

P: n/a
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

Expand|Select|Wrap|Line Numbers
  1. document.write('<img width="1" height="1"
  2. src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' +
  3. screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth +
  4. '">\n');
  5.  

Oct 4 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
>> '">\n');

\n is a Javascript escape value for a new line

Oct 4 '05 #2

P: n/a
"Tobierre" <No******@hotmail.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

Expand|Select|Wrap|Line Numbers
  1. document.write('<img width="1" height="1"
  2. src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' +
  3. screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth +
  4. '">\n');


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

--
Spartanicus
Oct 4 '05 #3

P: n/a
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" <in*****@invalid.invalid>
Newsgroups: comp.lang.javascript
Sent: Tuesday, October 04, 2005 9:09 AM
Subject: Re: .js include creates extra line in html display

"Tobierre" <No******@hotmail.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

Expand|Select|Wrap|Line Numbers
  1. document.write('<img width="1" height="1"
  2. src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' +
  3. screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth
  4. +
  5. '">\n');

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

--
Spartanicus


"Spartanicus" <in*****@invalid.invalid> wrote in message
news:q9********************************@news.spart anicus.utvinternet.ie... "Tobierre" <No******@hotmail.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

Expand|Select|Wrap|Line Numbers
  1. document.write('<img width="1" height="1"
  2. src="http://www.mydomain.com/log_analysis_screen_info.gif?' + 'width=' +
  3. screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth
  4. +
  5. '">\n');


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

--
Spartanicus

Oct 4 '05 #4

P: n/a
> 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>

Oct 4 '05 #5

P: n/a
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" <tw*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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>

Oct 4 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.