Get source url of script tag in Javascript on the iPhone over 3G -
i have javascript widget embedded on third party websites. needs load other resources (css, flash, etc) relative (rather relative page hosted on).
to have been looping through script tags in page, finding script tag, , getting src
property it.
e.g.
path = ''; $('script').each(function(i, script) { var src = $(script).attr('src'); if ('name-of-widgets-file.js' === src.replace(/^.*[\/\\]/g, '')) { return path = src.substring(0, src.lastindexof('/')); } });
this works on devices have tried on, except iphone on 3g connection! when connected on 3g iphone returns undefined
src
attribute of script tag!
does have ideas working around this? possibly way url of executing script tag?
i've found work around this.
rather looking script after has run, work out path
while script executing. in case iphone returns src
attribute when on 3g connection.
var scripts = document.getelementsbytagname('script'); var script = scripts[scripts.length - 1]; var src = script.src; if (!src) { return ''; } return src.substring(0, src.lastindexof('/'));
Comments
Post a Comment