JavaScript – iframe inline, iframe freehand, iframe src freedom
IFRAME , you want to use, and it doesnt work, using .src? It works how you want it to work, check following.
case ‘Duplicates’:{
// [ Putting ] — Headings
$( ‘a.databaseB’ ).html( ‘(Duplicates)’ );
// [ load and progress bar show ] – xhtml/css
myAjax(‘include/add_edit_del.php?model=ajax_loginput’, ‘oper=search&about=Duplicates’);
// [ load a largest 40,000 lines of tables ] – xhtml/css and SQL database
var db = myAjaxReturn(‘include/add_edit_del.php?model=ajax_duplicates’, ‘oper=search&about=Databases’);
// [ Also i want some ajax events attached ] – pure javascript my class and libraries.
_html = ”;/**
* The meat of IFRAME
*/
// [ { This is what you are looking for } ] — IE5 till IE8 and FF,Chrome,Opera works for me
var frame = ‘<iframe frameborder=”1″ width=”100%” height=”400px” id=”companiesframe” name=”companiesframe” src=”javascript: \’\';” > ‘;
// [ Place where i want to put the iframe visible] — I use iframe for performance and dealing largest displays.
$(‘#database_b’).empty().append( frame) ;// [ Now it doesnt work! ] – so i confirm the element initialized mannually
$(‘#companiesframe’).load(function(){
try {
// [ Now plain xhtml/css/js simply copy and past] — done!
$(this).contents().find(‘body’).html( db );
}catch(e){
// if anything happens. Lets rock here…
}
});
// End of the Meat.// — Thanks
// — Shamun
// — follow me: http://shamuntoha.wordpress.com
}break;
// weather plugin
(function($){
// Briefcase of variable
var _css;
var _html;
var _tmp;
var _tmp0;
var _tags;
// Ajax Query
$.fn.shweather = function( param ){
_root = $(this);
/*
* we could have done this in js the file weather.php is just doing this
* header( "content-type: text/xml" );
* $html = file_get_contents( 'http://www.google.com/ig/api?weather=Huizingen,Belgium&hell=?' );
* echo $html;
*
*/
$.ajax ({
type: 'GET',
url: 'weather.php',
data: 'q=' + param.caption,
success: function( msg ){
// current details
$(msg).find( 'current_conditions' ).children().each( function(i,v) {
//alert ( source );
_tags = ( $(v).get(0).tagName ) ;
switch(_tags){
case 'icon':
var source = $(v).attr( 'data' );
source = source.replace( '/ig/images/weather/' , 'images/' );
_tmp += '<div><img src="' + source + '" width="100%" height="100%" /></div>';
break;
case 'temp_c':
var source = $(v).attr( 'data' );
//source = source.replace( '/ig/images/weather/' , 'images/' );
_tmp = '<div>' + source +'°</div>';
break;
}
});
// next day
$(msg).find( 'forecast_conditions' ).next( 'forecast_conditions' ).children().each( function( i,v ){
// var source = $(v).attr( 'data' );
// source = source.replace( '/ig/images/weather/' , 'images/' );
// alert the source > replace the text in, to text out
// alert ( source );
_tags = ( $(v).get(0).tagName ) ;
switch(_tags){
case 'icon':
var source = $(v).attr( 'data' );
source = source.replace( '/ig/images/weather/' , 'images/' );
_tmp0 += '<div><img src="' + source + '" width="100%" height="100%" /></div>';
break;
case 'day_of_week':
var source = $(v).attr( 'data' );
//source = source.replace( '/ig/images/weather/' , 'images/' );
_tmp0 = '<div>Morgen</div>';
break;
}
});
// pain the view
_css = '<style> .icon { width:60px; height:55px; padding:3px;border:solid 1px #aaaaaa; } .tempc {color:#5a5a5a; font-weight:bold; } </style>';
_html = '<table width="100%"><tbody><tr><td>' + _tmp + '</td>\
<td>' + _tmp0 + '</td></tr></tbody> <tbody><tr> <td colspan=2 align="center"> <input style="border:solid 1px #cccccc;font-size:10px;width:100%;" name="caption" /> </td> </tr></tbody> </table>';
// alert ( _html );
_root.empty().append( _css + _html );
_root.find('[name="caption"]').val( param.caption );
_root.find('[name="caption"]').dblclick( function(){_root.shweather({caption: $(this).val() }); });
}
});
}
})(jQuery);
$('#weather').shweather({caption:'Huizingen,Belgium '});
Download:
http://dpaste.de/gOXE/
