BUG ? : JAVASCRIPT in HTML block, shows plain HTML

Permalink
When I add JAVASCRIPT to HTML block, and save it. Instead of return to normal view of website it shows only blank HTML of that HTML block.

Here I am trying to add select box with JAVASCRIPT on HTML block , but on saving it, it shows only select box. I have attached screenshot.

Is it bug ?

1 Attachment

srjahir32
 
HardOne replied on at Permalink Reply
HardOne
As the block name says, it's html only. Please use one of the php blocks available at the marketplace.
MrKDilkington replied on at Permalink Reply
MrKDilkington
@HardOne

The HTML block accepts HTML and JavaScript.

@srjahir32

What is the code you are trying to add to the HTML block?

Do you have a link to the website where this code was added?
srjahir32 replied on at Permalink Reply
srjahir32
http://exrx.net/concrete5/home/home-8
There is select box, Exrx.net Quick LInks.
MrKDilkington replied on at Permalink Reply 1 Attachment
MrKDilkington
I attached a screenshot of what I see. It does not look like the screenshot you included in your post.
srjahir32 replied on at Permalink Reply
srjahir32
Actually when you copy Javascript code in HTML block and save it, all things goes blank except Select menu as my screenshot. Then you have to again refresh page, to get back page.

Here is that JS code,
<script LANGUAGE="JavaScript">
var sid="mitnamdliw_wildmantim";
function selectaplace(form) {
var appname= navigator.appName;
var appversion=parseInt(navigator.appVersion);
if (appname == "Netscape" && appversion >= 3) {
var formindex=form.select1.selectedIndex;
var storage=form.select1.options[formindex].text;
if (form.select1.options[formindex].value != "none") {
var msg=storage+"You are now being transferred to the -> "+storage;
for (var spot=0;spot<msg.length-storage.length;spot++) {
var x=msg.substring(spot,msg.length);
form.select1.options[formindex].text=x;
for(var d=0;d<150;d++) { };
}
srjahir32 replied on at Permalink Reply
srjahir32
What could be affecting then, do i need to change javascript ?
goodnightfirefly replied on at Permalink Reply
goodnightfirefly
Don't be suprised when problems come up when you use code that was written in 1997: http://www.htmlgoodies.com/JSBook/drop.txt...
srjahir32 replied on at Permalink Reply
srjahir32
Yes, It is. But can you tell me what is the reason for it. Which code snippet is making it to work like this ?
goodnightfirefly replied on at Permalink Best Answer Reply
goodnightfirefly
I don't know if this will solve your problem but at least it is vastly improved.

<script type="text/javascript">
  function selectAPlace(form) {
    var formIndex = form.select1.selectedIndex;
    window.location = form.select1.options[formIndex].value;
  }
</script>
<form>
  <select id="select1" onChange="selectAPlace(this.form)" style="width:100%;" class="Add-Margin-Bottom">
    <option value="index.html">ExRx.net Quick Links</option>
    <option value="Lists/Directory.html">Exercise & Muscle Directory</option>
    <option value="Lists/OlympicWeightlifting.html">Weightlifting Exercises</option>
    <option value="Lists/PowerExercises.html">Plyometric Exercises</option>
    <option value="Lists/KettlebellExercises.html">Kettlebell Exercises</option>
    <option value="Lists/CardioExercises.html">Cardio Exercises</option>
    <option value="Lists/OtherExercises.html">Other Exercises</option>
srjahir32 replied on at Permalink Reply
srjahir32
Thank you. This code works very well with HTML block.
HardOne replied on at Permalink Reply
HardOne
Whoops, I'm sorry.

Some time ago I've accidentially used html block to try something out and had the same experience that js was not working together with that block. As I normally don't use this block, I didn't try to find out what's wrong, instead I blamed the block. ;-)