Web Analytics Made Easy -
StatCounter Does this computer see mpos2? if not, why? - CodingForum

Announcement

Collapse
No announcement yet.

Does this computer see mpos2? if not, why?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does this computer see mpos2? if not, why?

    var input = window.prompt("Enter Text Here","see this: [[Image:wiki-en.png|Wikipedia]]");
    var mpos1 = input.indexOf("[[Image");

    for(i=mpos1;i<=input.length;i++)
    {
    var mpos2 = input.indexOf(":");
    }

    var istr1 = input.substring(mpos1, mpos2);

  • #2
    Look to the bottom for the problem:

    <script type= "text/javascript">
    var input = window.prompt("Enter Text Here","see this: [[Image:wiki-en.png|Wikipedia]]");
    var mpos1 = input.indexOf("[[Image:");
    var init = "[[Image:"
    var colon = init.lastIndexOf(":")

    for(i=mpos1;i<=input.length;i++)
    {
    var mpos2 = input.indexOf("|");
    }
    for(i=mpos1;i<=input.length;i++)
    {
    var mpos3 = input.indexOf("]]");
    }
    var istr0 = input.substring(0, mpos1)
    var istr1 = input.substring(mpos1, colon);
    var websi = input.substring(colon, mpos2)
    var istr2 = input.substring(mpos2, mpos2+1);
    var istr3 = input.substring(mpos2+1, mpos3);
    var istr4 = input.substring(mpos3, mpos3+2);
    var istr5 = input.substring(mpos3+2, input.length);

    if(istr1.indexOf("[[Image:") != -1)
    {
    var ipos1 = istr1.replace("[[Image:", '<img src="http://en.wikipedia.org/wiki/Image:');
    }

    if(istr2.indexOf("|") != -1)
    {
    var ipos2 = istr2.replace("|", '" alt="');
    }
    if(istr4.indexOf("]]") != -1)
    {
    var ipos3 = istr4.replace("]]", '</img>"');
    }
    var newimage = (istr0+ipos1+websi+ipos2+istr3+ipos3+istr5);
    document.write(newimage);
    ----

    when I output this, it doesn't output ipos1.
    It doesn't even transform it.

    I'm thinkin it has to do with the fact that i can't find mpos2.

    Comment

    Working...
    X