Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
71
rated 0 times [  75] [ 4]  / answers: 1 / hits: 192429  / 13 Years ago, mon, september 26, 2011, 12:00:00

I have a main page (actually a JSP) with an iframe inside it as;



<iframe name=abc_frame id=abc_frame src=about:blank frameborder=0 scrolling=no></iframe>


Now there are multiple links on the main page (rendered dynamically via JSP) which can try to set the src to some URL...



Now my question is,using jQuery (may be live()), can I override that in such a way that the src attribute for abc_frame would always have some particular value (e.g. somefixedURL)



I cannot capture the link clicking, as it is completely dynamically created via some Java code and hence I am trying to override the iframe src ?


More From » jquery

 Answers
17

Use attr



$('#abc_frame').attr('src', url)


This way you can get and set every HTML tag attribute. Note that there is also .prop(). See .prop() vs .attr() about the differences. Short version: .attr() is used for attributes as they are written in HTML source code and .prop() is for all that JavaScript attached to the DOM element.


[#89927] Friday, September 23, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
billt

Total Points: 608
Total Questions: 100
Total Answers: 87

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
;