I need to load a url in an iframe on page load (which is working), then grab the whole url of that loaded iframe, then once the url is saved as a variable i want to find any text between "target" and "/" (example url http://www.example.com/user/target09576/index.php i wish to find the 09576) then redirect the whole page using the found text (09576) as part of the redirect url.
I know, bad explanation and not a great solution, but any help would be appreciated.
$(document).ready(function() {
var iframe = $('#wmif');
var url = '<? echo "".$redirectlocation.""; ?>';
iframe.attr('src', url);
var searchurl = iframe.contentWindow.location;
var rep = /(.*target\s+)(.*)(\s+\/.*)/;
var target = searchurl.replace(rep, '$2');
window.location = 'http://example.com/go/index.php?target='+target;
});
well the iframe loads the new location ok, but it doesn't do any of the rest.
target\s+which maybe should betarget\s*