jQuery: working within iframe without re-linking -


maybe title little misleading , question too, i'm curious, how 1 work jquery internal (same host/domain) iframe without re-linking jquery's source in iframe's loaded html.

well, i'm able access parent.jquery();, whenever i'm trying manipulate elements it, works in parent frame not current, active one.

iframe generated colorbox v.1.3.16.

here i've tried far, no luck @ all.. (this comes within iframe):

jquery = parent.jquery; jquery(document).ready(function(){     jquery('#time-bar .slider', document).css({ 'background-color' : 'blue', 'left' : '-99%' }); }); 

i've used document parent selector here, doesn't work, , have no idea should used there.

thanks in advance!

edit:

derived t.j. crowder:

parent.jquery(function($) {     var element = $("#time-bar", document);     console.log(element); }); 

console.log() returns empty object, or actually, have no idea if can called object: [].

barring other factors, code passing in document jquery() ($()) function context document should work.

example:

html:

<script src="blah/blah/jquery.min.js"></script> <iframe id='theframe' src='http://jsbin.com/ulehi4'> 

iframe html:

<input type='button' id='thebutton' value='click me'> 

iframe javascript:

parent.jquery(function($) {   $("#thebutton", document).click(function() {     $("<p>button clicked!</p>").appendto(document.body);   }); }); 

live example

that said, though, if use same exact link jquery file (perhaps 1 of cdns it's in) in both parent , frame, there's little overhead indeed. can insert script element in iframe if you're not in control of markup.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -