Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a problem and an try to find in one week. I need help :(

I have a script work with :

<script type="text/javascript">
var list_images = 'image1.jpg|image2.jpg|image3.jpg|image4.jpg|image5.jpg|image6.jpg|image7.jpg';
var images = list_images.split('|');
</script>

but know in blogger always give more tab in my script

<script type="text/javascript">
var list_images = '

<div></div>
<a herf="anything"><img src="image1.jpg"><a/>
<a herf="anything"><img src="image2.jpg"><a/>
<a herf="anything"><img src="image3.jpg"><a/>
<a herf="anything"><img src="image4.jpg"><a/>
<a herf="anything"><img src="image5.jpg"><a/>
<li><img src="image6.jpg"></li>
<li><img src="image7.jpg"></li>
<br/>

';
var images = list_images.split('|');
</script>

I want remove all tabd and convernt them like

var list_images = 'image1.jpg|image2.jpg|image3.jpg|image4.jpg|image5.jpg|image6.jpg|image7.jpg';
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
285 views
Welcome To Ask or Share your Answers For Others

1 Answer

The Blogger editor is unfortunately not designed well to handle code blocks.

By default, it adds a <br/> tag to the end of every line causing your well formatted script to fail.

The only workaround I've seen so far isn't pretty.

<script type="text/javascript">/*
  */var list_images = /*
  */'image1.jpg|image2.jpg|image3.jpg|image4.jpg|image5.jpg|image6.jpg|image7.jpg';/*
  */var images = list_images.split('|');/*
*/</script>

Essentially everything after then end of a line up to the begining of the next line is forced to be a comment so that when Blogger injects the <br/> tags they are ignored by the browser.

Result after Blogger injects the BRs:

<script type="text/javascript">/*<br/>
  */var list_images = /*<br/>
  */'image1.jpg|image2.jpg|image3.jpg|image4.jpg|image5.jpg|image6.jpg|image7.jpg';/*<br/>
  */var images = list_images.split('|');/*<br/>
*/</script><br/>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...