开发者

GetElementById Value in a src tag

Hi I have the following iFrame and I would like to get the number by ID between SID= and the &ACT can anyone help?

<IFRAME  ID=开发者_开发问答CoachingCaptionFrame SRC=/CRM7Dev/eware.dll/Do?SID=189796409459332&Act=1696&Mode=1&CLk=T&FldCoachingActionID=Act49791Key1&AAct=200  STYLE="display:none;"  ></IFRAME

Cheers

Justin


function getSrc() {
var frame = document.getElementById('myframe');
var start = frame.src.indexOf("SID=", 0) + 4;
var end = frame.src.indexOf("&ACT", 0);
var hdnInput = document.getElementById('inputId');
hdnInput.value = frame.src.substring(start, end);
}

Haven't tested it but it should work.


Using jquery,

$('#CoachingCaptionFrame").attr('src').val()

Will get you close, then you can split on a delimiter.


var str = document.getElementById("CoachingCaptionFrame").src;
var matches = str.match(/SID=((.)*)&Act/i);
alert(matches[1]);


You can use the string object's split() function to do these kind of stuff(extracting arguments off a URL).

var frameSrc = document.getElementById('CoachingCaptionFrame').src;
var SID = frameSrc.split("?")[1].split("&")[0].split("=")[1];
var hiddenInput = document.getElementById("hiddenInputId");
hiddenInput.value = SID;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜