JavaScript Get url from iframe and onclick modify the address

I'm trying to find a way to get a url from an iframe and using javascript modify the link and move to a another page. basicly the address in the iframe is something like "http://www.somthing.com/12/somt/arr_1.htm", using the javascript I want to remove the last five character (leaving this "http://www.somthing.com/12/somt/arr_") and than add the next logical number to it (making the link this "http://www.somthing.com/12/somt/arr__2.htm").

So far I have something like this.

    <script language="javascript" type="text/javascript">
    function urlGen(f){
                       var i1 = document.getElementById("iframe_id").contentWindow.location.href;
                       var i2 = "1.htm";
                       var i3 = "2.htm";
                       var newURL = i1 - i2 + i3
                       f.action = i1 - i2 + i3
                       return i1 - i2 + i3;
                       }
</script>

So based on what I understand from what you said it should look something like this? so it should look something like this? (keep in mind I'm the forest gump of javascript... "I'm not a smart man but I know what java is")

    <script language="javascript" type="text/javascript">
    function urlGen(f){
                       var i1 = document.getElementById("iframe_id").contentWindow.location.href = newURL;
                       newURL = il.slice(0, -5);
                       var i3 = "2.htm";

                       f.action = newURL + i3
                       }
</script>
Answer:1

Try with this regular expression match

var i1 = "http://www.somthing.com/12/somt/arr_41.htm";

s = i1.replace(/\d+\.htm$/, function(attr) {
  return attr.replace(/\d+/, function(val) {
    return parseInt(val,10) + 1;
  });
});


alert(s);
Answer:2

Here's a replication of the problem: I get the timestamp of now via JavaScript as var ts = +new Date // 1368971991090 console.log( new Date(1368971991090) ); // Sun May 19 2013 13:59:51 GMT+0000 (GMT)...

Here's a replication of the problem: I get the timestamp of now via JavaScript as var ts = +new Date // 1368971991090 console.log( new Date(1368971991090) ); // Sun May 19 2013 13:59:51 GMT+0000 (GMT)...

I am using the following coding for the script in external file function DiableLink(elem){ console.log($(elem).attr('type')); if($(elem).hasClass('disabled')) { return false; } ...

I am using the following coding for the script in external file function DiableLink(elem){ console.log($(elem).attr('type')); if($(elem).hasClass('disabled')) { return false; } ...

I am receiving the following message when I try to use Backbone's collection.each() method: TypeError: Object function (){ return parent.apply(this, arguments); } has no method 'each'. I'm learning ...

I am receiving the following message when I try to use Backbone's collection.each() method: TypeError: Object function (){ return parent.apply(this, arguments); } has no method 'each'. I'm learning ...

  1. backbone collection each example
  2. backbone collection each
  3. backbone collection each break
  4. backbone js collection each
  5. backbone collection foreach
  6. backbone this.collection.each is not a function

I have a bunch of title texts that get generated they all have different .Length but at a specific startindex of the string I want to find the closest space and then remove the text after it and also ...

I have a bunch of title texts that get generated they all have different .Length but at a specific startindex of the string I want to find the closest space and then remove the text after it and also ...