Troy III 272 Posting Pro

and found that
Firefox 15.01 will play the ogg, but not the mp3.
IE8 won't play anything.
Chrome (Version 22.0.1229.92 m) will play both.

That's ironic because the following will play in any Internet Explorer, say version 0 through IE10 if you like.

Without even having to make use the <bgsound> element, I will demonstrate here the posibility of playing audio files without plug-ins using plain <img> tag; to (among other multimedia files) also play a separate audio file (mp3 in this demo). The supported formats are limited only by the number/variety of formats your current OS can play independently.

<!DOCTYPE html>
<html>
  <head>
   <basefont face="geneva, arial, helvetica" size=2 color=#555555>
  </head>
<body>

<div align=center>
   <h1>   The Policy Of Truth  </h1>

   <img id=audio title="right-click for [ Play : Pause / Stop ] commands"
        src=http://t0.gstatic.com/images?q=tbn:ANd9GcR8cqxyVAIUQwMiijsXV3Z6fru33gnRIJYONVzJmBaV7z1LPIc0
        border=0 height=180 width=244 
    dynsrc=http://www.soundcat.ch/download.php?id=13477
        controls
  >
  <br>
  <div id=inf>
     <img src=http://www.nantucketsound.com/images/loading.gif><br>
    wait for file download 
  </div>
</div>

<script>

    document.
    onreadystatechange = 

    function(){
        if(audio.complete)
            inf.innerHTML  = audio.mimeType + "<br>",
            inf.innerHTML += ( audio.fileSize / 1024  / 1024 ).toPrecision(4) + " MB";
        }

</script>
</body>
</html>

p.s.: The file linked is not a stream, -meaning: will not play before it is fully loaded!

Troy III 272 Posting Pro

Thanks for the feedback lol but applepie-0167 is obviously thinking javascript while saying java, and this, of course is a javascrip section, therefore a javascript solutions will be served.
p.s. There's no 'String.reverse' method in javascript either, but there we are. It's the power of Live Script at work! :)

Troy III 272 Posting Pro

Write a program that defines and instantiates a new String object called title with COMPUTER PROGRAMMING in it. Then create a new String labeled title2 -- write code to store the contents of title into title1 in reverse order. Using a for loop and charAt.

You don't need a loop nor a charAt method for this task; The "for in" is sllower + collects colaterals, -you don't need the "charAt" either (also sllow and completely unnecesary). String Objects are also sllow, string literals are faster. So instead of learning the worst approach possible even if being suggested by your school, I propose a professional and efficient coding which will in some degre, satisfy both sides:

var title = "COMPUTER PROGRAMMING",
    title1 = new String( title ), 
    title2 = new String(title.split("").reverse().join(""));

title2 >> "GNIMMARGORP RETUPMOC"

Troy III 272 Posting Pro

you can't do that!

Troy III 272 Posting Pro

Is there any code snippets for that. I need the code. WHAT IS THE NAME OF THIS EFFECT?

It's called "accordion" and there are plenty of them: you can try this one among others
http://sandbox.scriptiny.com/accordion/index.html

Troy III 272 Posting Pro

you've most probably lost refference to your counter (i)

Troy III 272 Posting Pro
  1. You shouldn't append script element to a div or any other structural element of the document except the two main elements of the document: document body and document head.

  2. The src attribute of script element is (recently) flagged, and pasting script element as innerHTML will probably not trigger the load, while appending a new script element by DOM, may trigger, -but only once.

  3. Your mentioned methods are successful in creating a new script element, except that they will refuse to load the external file. So the only way to go with this, is appending a new script element to the document body or the document head using DOM methods while targeting legitimate elements; i.e.: document.body & document.head.

Troy III 272 Posting Pro

Troy III, thanks for the help, but there isn't any way to do it with animations/transitions?

There is, but I don't like fixed things,
-however, this will do until you find a better approach.

demo:
http://jsfiddle.net/KWUHy/6/

the snip:

   activate : syncAttr(lineTop.style, "backgroundColor", menu.children);    

     function syncAttr(t, a, x){
            function cS(x){return getComputedStyle(x,0)||x.currentStyle};
            var L = x[0] ? x : [x], i = 0, z,tm;
            while(L[i]){ 
                L[i].onmouseout = function(){t[a]="";clearInterval(tm)};
                L[i++].onmouseover= attSync;}
            function attSync(){z=this; 
                tm=setInterval(function(){
                if(/rgba|tran/.test(cS(z)[a])){ t[a]=cS(z)[a];
                }else{ t[a]=cS(z)[a]; clearInterval(tm) }},8)}
            }
Troy III 272 Posting Pro

do you use a separate towel on each hand?!
-well than, you'll need to take it easy on those CSS definitions.

This is the exact equivalent of your existing css, [except that it is at least 1/4 times shorter].

.linha {
          width: 100%;
          height: 3px;
          background-color: #E51400;
}
#menu {
        width: 100%;
        text-align: center;
        font-weight: 400;
        font-size: 1.6em;
        color: #333;
}
.home,.contato,.trabalhos,.experimentos  {
        text-decoration: none;
        border-bottom-width: 1px;
        border-bottom-style: dotted;
        border-bottom-color: #E51400;
        padding-right: 5px;
        padding-left: 5px;
        margin: 10px;
        -webkit-transition: all .2s ease-in-out 0s;
        -moz-transition: all .2s ease-in-out 0s;
        -ms-transition: all .2s ease-in-out 0s;
        -o-transition: all .2s ease-in-out 0s;
        transition: all .2s ease-in-out 0s;
        color: #333;
}

.home:hover,.home.active {
          background-color: #E51400;
          color: #fff;
}
.trabalhos:hover,.trabalhos.active {
        background-color: #8CBF26;
        border-bottom-color: #8CBF26;
        color: #fff;
}

.experimentos:hover,.experimentos.active {
        background-color: #6E155F;
        color: #fff;
        border-bottom-color: #6E155F;
}
.contato:hover,.contato.active {
        background-color: #1BA1E2;
        border-bottom-color: #1BA1E2;
        color: #fff;
}

but even this can stand a trial for further optimizations.

***

The following JavaScript function can do your thing, - if you agree to remove css transitions...

   activate : syncAttr(lineTop.style, "backgroundColor", menu.children);    
     function syncAttr(t, a, x){
            function cS(x){return getComputedStyle(x,0) || x.currentStyle};
            var L = x[0] ? x : [x], i = 0;
            while(L[i]){ 
                L[i].onmouseover= attSync;
                L[i].onmouseout = function(){t[a]=""};
            i++;}
            function attSync(){t[a] = cS(this)[a]}
            }

The code is assuming that: <div class="linha"></div> has an id=lineTop. That is <div id=lineTop class=linha></div>.

But as mentioned; Will not work with css transitions enabled.

Troy III 272 Posting Pro

That's because HTML5 is the boss of his own now.

The second one should be invalid, since p2 isn't defined. That shouldn't work.

-Why would you say that?

p.s.:

<p id="p1">Hello World!</p>

This is not important, but FYI:
<P>, doesn't need an ending instruction on HTML.

Troy III 272 Posting Pro

This is not impossible to do with CSS if the elements are next to each other. It's not recommended to rely on that though in case elements get moved around but here is how it's done just as an FYI:

True,
but you should warn about browser compatibility;
-not all versions support pseudo-classes on ordinary elements;

Love your hair though :)

Troy III 272 Posting Pro

Quoted Text Here

Hmm... Not sure what that mean... :( Too vauge... Anyway, the example I made is just to show a very simple wayt to change background color using mouse event of each element. May not be a solution. :)

The sentence: "trying to change an element background color when my mouse goes over another element."
would usually mean: I need to change the background of element B, when element A is hovered :p

My Spartan (universal property toggle) happens to be the right tool for the job since it is not bound to the event source element, therefore its action can arbitrarilly target any element on the document, on an iframe, on a popup window; including itself. ;)

Troy III 272 Posting Pro

"trying to change an element background color when my mouse goes over another element."

Troy III 272 Posting Pro
toggleXprop=
    function(o,p,v){
            o.m||(o.m={});
            o[p]==v?o[p]=o.m[p]:(o.m[p]=o[p],o[p]=v);
    }

usage:

handlerElement.setAttribute("onmouseover", 
     "toggleXprop(targetElement.style, 'backgroundColor', 'colorVal')");

handlerElement.setAttribute("onmouseout",
     "toggleXprop(targetElement.style, 'backgroundColor', '')");
Troy III 272 Posting Pro

it is possible, of course, but what do you have so far, can we see your code?

Troy III 272 Posting Pro

I think that "referrer" is a property of "document" object.

Troy III 272 Posting Pro

It must be a jQuery bug, so you should try a fix with them.
Input doesn't have a "closing tag" and most often it will cause DOM errors.

tip:
You don't use xhtml syntax when coding in HTML.

Troy III 272 Posting Pro

I totally agree, but I was trying to make a point that:
- it is always a better choice to eliminate mistakes instead of fixing them with aditional code.
Say, correct the textbox "... value=null>" which is wrong, with a proper type ... value=""> instead.

Troy III 272 Posting Pro

...the default value of a textbox should always correspond to, at least the type of an expected value -which in this case, is a string("");
Strings can contain numerals also, but not objects. And null is exactly that, -a* Typeless Emty Object*, but nonetheless an object; of which parseFloat is not very found of, since it expects a string containing numbers or at least an object of that type Number.
-Anything else will fail on conversion and return a "not a number" Number object.

Troy III 272 Posting Pro

A simplified illustration of what i meant:

window.onload = function(){
   var i = 0, srcArray, imgTest;
   srcArray = "mg1.jpg,img2.jpeg,img3.jpg,imgx.jpg".split(",");

   initiator: newImage();

   function newImage(){
         imgTest = new Image();
         imgTest.onload = loadNext;
         imgTest.onerror = finishSeq;
         imgTest.src = srcArray[i]}

   function loadNext(){ imgSeq.appendChild( imgTest );
                        i++; newImage();
                        };
   function finishSeq(){ slide(imgSeq) };
}
Troy III 272 Posting Pro

that doesn't mean that everything works,
it means that you are invoking the loadNext command arbitrarily during the loop.

What you need is the initiator followed by:
"testerImage" supplied with "onLoad(loadNext)" and "onError("finish -feed the slider")" handlers by default; where the "loadNext" feeds the new image source from your array each time it is invoked.

You don't need the while loop at all.

Troy III 272 Posting Pro

I don't understand why does an empty textbox contain null value in the first place?

Troy III 272 Posting Pro

You need to try your code on IE first. If it works there, and it most probably will.
the problem is the brwoser you are using.

Meaning, the [img][src] attribute has been flagged.
You will most probably be forced to use some sort of a hidden iframe to actually load images before you are going to be able to trigger 'the image not fund' error on them.

Troy III 272 Posting Pro

I think that you are having a "soft refresh" instead.
To get a "hard refresh", you'll have to "Shift + F5" it!

Troy III 272 Posting Pro

Try this:

_.radios.onclick=function(e){
        e=e||event;e=e.target||e.srcElement;
            e.value==="1"?
            _.divtext.style.display="none":
            _.divtext.style.display="block";
    }

!Dependency: The UnderDot Platform
(provided on the link).

Troy III 272 Posting Pro

Hi Taywin, thanks for your suggestion.
I think there was a reason behind this decision...

Its about freedom

And freedom is about more choices, more opportunities, more solutions and so forth.
To my humble opinion -there are always more good people, than bad.

Henceforth, contrary to the widespread policy/opinion that treats them all as equally evil, yet privilege the most unworthy ones - in reality and in practice, it is always just, and easier than anything else - to restrain the evil ones only, and let others enjoy.

The freedom where you are free to do nothing, is no freedom at all.
-It's a quarantine!
My natural borne idea was/is to make freedom enjoyable. (For, what good is freedom that you cant enjoy?!)

Anyway,
as mentioned earlier, - "to some degree" - the code is also customizable;
and so is its policy -which can easilly be inverted:

// just add the "!" [NOT] mark here and fill in your whitelist: 
for( x in c )
    if( ! /(/*your white-list here*/)/i.
    //and continue;

than comment out the "else" part completely:

// } else {

and you got yourself a privileged list of tags allowed, instead.

p.s.
You might notice that - depending on "how you look at freedom", - the privileged list will tend to extend far beyond the length of its opposite.

My Best Regards.

Troy III 272 Posting Pro

This is a simple HTML String Sanitizing tool.

It allows a highly rich,- but safe - html content input to be published on your pages.

The script code is very light and to some degree customizable.

  • This function takes care of blacklisted tags, which are the first to be discarded without further processing.
  • Otherwise, it checks link protocols for code injection, and strips it off if JavaScript is encountered.
  • Further on, it removes all event driven code assignments from event attributes on all tags.
  • And lastly, it restores images after stripping their event attributes. This security step is taken directly on the string source, because images are able to trigger the onerror event on a faulty source as soon as they are converted to DOM Elements, - making it possible for the attacker to execute his malicious code even before appending it to the document. This is the only part of the measure that operates on a string level. But it's absolutely, - a necessary one!

All questions, suggestions or remarks, are welcome...

p.s.: just before posting, I decided to also restrict the use of inline style, -since earlier versions of IE do support JavaScript returned values on this property.

JorgeM commented: nicely done. +10
Taywin commented: Clear description +11
Troy III 272 Posting Pro

And finally:
are you interested in counting all the typing errors as you go, or only the errors reflected at the final output?

The answer to this question is very important since it shapes the backbone of the algorithm.

Troy III 272 Posting Pro

I still cannot find an adequate use for sleep/wait or any command of the kind, on any possible scenario.
Can anybody find me one?

Troy III 272 Posting Pro

Hello, i am making a keyboarding site for my class, and i have a div with some text inside, when they type, i want to check if the text matches the text in the div, if it dosn't, i wan't to update a box with an "error count". How can i achive this?

Is this a typing practice class?

zacharysr commented: Yes this is for a class in my highschool. I am making it for my teacher +0
Troy III 272 Posting Pro

They have no idea what they are typing all they see is black dots as well since it is "hidden" This is not a particularly security sensitive area and we would MUCH rather these were visible to the people typing them. They get new ones every two weeks anyway.

That's the reason you have a "password [field]" followed by a "confirm password [field]", so that if there was a typing error on one of them the fields will not match and the pass will not be accepted until corrected.

Troy III 272 Posting Pro

I thought so... :) -additionally,
it is also the major reason a lot of people did; (ie, started using jQuery and alike).

The need for these was rised with W3C introduction of the "document.getElementById('id')" which in fact, is a failsafe method.

I always thought that somebody else ( or even lots of others ) will soon come up with the same solution.
-But, "it's been while…"

The underDot is the shortest platform possible;
It allows you to target elements (almost) the way it was meant to:

_.elementID; and even when using wrong ID definition as: _["my Element ID"] ;

The benefits:
Most of the time, people are using heavy libs, just so they can avoid the "document.getElementById" syntax and target them more naturally like "hey('Jim')", instead of say "cityCouncil.getMeTheCitizenWithID('Jim')";
which in turn, does good to the web as a whole. Because, to much bandwidth is being wasted on long robust lines of code (that are never being used in practice), already. And your own code becomes shorter cleaner and more straightforward.

You also don't have to wait for the page load, or DOM init., or browser detection for this feature to become available.

Troy III 272 Posting Pro

The reason I never started using js libs...

Troy III 272 Posting Pro

Perfectly safe.
A DOM Collection, is not an Array.
Inerently -perfectly faster!

Troy III 272 Posting Pro

With this Spartan, we can destructively disable all the links on the page.
(Or whatever link collection we feed the Fn.arg.)

Troy III 272 Posting Pro

Literally, NaN stands for not a number.

NaN is a javascript object returned when a value treated as a number fails to convert to number. Basically it is not a number. Whereas the type of NaN it self, is - a number container that has no value. (It's not even a zero).

It's a box of numbers alright - but it's empty. Therefore (another) NaN is never equal to (previous/following) NaN, because it's a different box.

You cannot check if( Number("1.a") == NaN )
That's why isNaN() function was needed.

Though NaN==NaN >> is always false!
It's not a Voodoo..., since NaN is an Object;

It's the same as with other empty objects, say: []==[] >> false! They mey be equal in the sense of emptyness and type etc, alas, they are not the same "box". They are different instances of that type of objects.

Contrary to abstractions that can be equal, say 1==1 > true, -since all the 1's of the world are that same 1 (one). That is, the same abstraction. They (NaN's), will be compared by instances, not by values { as in say Number(1)==Number(1) >> true}, because there is a value of the same type that can be compared there. And since they belong to the same abstraction (1) they are the same. >> true!

p.s.:
There are a lot of highly "professional coders" that don't understand the half of it. And ask questions like: why is the typeof NaN >> "number" - …

Troy III 272 Posting Pro

Try targeting an iFrame placeholder and populate it only after the page has loaded.

Troy III 272 Posting Pro

try the built-in function

isNaN(input)

Troy III 272 Posting Pro

...and the problem is?

Troy III 272 Posting Pro

That's exactly what it sohuld return.
You are trying to convert the string " hey " into a Number.
Actually NaN is the result of the given conversion.

var height = 55,newPositionValue = 12; 
console.log("Height is " + height + " New position value is " + newPositionValue + 
 + " hey ");

result *>> LOG: Height is 55 New position value is 12NaN *

The same will happen on IE dev also.

Troy III 272 Posting Pro

var p = document.createElement("input");
form.appendChild(p);

What do you mean by:

p.name = "p";

?

Troy III 272 Posting Pro

automatically bookmark website without asking user

No, thank you very much.

Troy III 272 Posting Pro

Good things about this are:

1.No eval()
2.Clear and short native code
3.No eval()
4.No eval()!!!

I would agree with the point 2,
if it were the 1st.
And only.

Troy III 272 Posting Pro

I already told you: there is no [].compact method in JavaScript Array Object(s).
And sorry, I don't use "komodo" nor anything of that kind.

Have you at least tried it without brackets?!

Troy III 272 Posting Pro

Not really, it's a property of the Object. Yet internally, it may, or meay not be a function.

Anyway, in more recent javascript you can write functions in a manner of object properties. For instance:
(I've recently posted this snip)

thisDay=
/*b.b. Troy III p.a.e*/{
    get Date(){return new Date().toLocaleDateString()},
    get Time(){return new Date().toLocaleTimeString()}
   }

With it you can call thisDay.Time same as in Array.lenth without brackets!

Troy III 272 Posting Pro

JavaScript is more like a Poetry -- Everybody can learn it -- But only few may turn...

Troy III

Troy III 272 Posting Pro

This little change in your conditional may guard you well enough

if(Number(inputValues[elem])<0){...
else if(Number(inputValues[elem]) > 35){...

Troy III 272 Posting Pro

if(inputValues[elem] < 0 ){

you are comparing a string literal type of data (like: "", " ", "abc", "123") against dynamic data type of a numeral 0, or a Boolean(false) in HEX mode; -Which will always evaluate to false.

if( "" < 0 ) //will aways return false because [""] is greater than [0].

Troy III 272 Posting Pro

Why would someone change the value of length property?

what is the advantage of doing that?

there are some good practical uses of it, but you haven't come to the point of needing them.

Troy III 272 Posting Pro

Any solution that don't use jquery......

only IE provides native support - other than that, there isn't any.