i'm trying find way url iframe , using javascript modify link , move page. basicly address in iframe "http://www.somthing.com/12/somt/arr_1.htm", using javascript want remove last 5 character (leaving "http://www.somthing.com/12/somt/arr_") , add next logical number (making link "http://www.somthing.com/12/somt/arr__2.htm").
so far have 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 understand said should this? should this? (keep in mind i'm forest gump of javascript... "i'm not smart man know 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>
try 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);
this change string ends in x.htm (where x digit) in same string x+1 in place of x (adapted https://stackoverflow.com/a/1742841).
Comments
Post a Comment