I've searched the entire web for a clear answer but haven't found one yet.
I have this site:
www.helixagent.com/todo/
and I want to load that entire site into a portlet in my main index page.
I tried an iFrame approach but it fails to load the site correctly. The styles and javascript files don't get loaded (i think)
Is there a way to make a portal that mimics a new browser page and load the content exactly as it would if it was directly accessed via the url bar?
It’s possible to perform cross-domain requests using jQuery.
Simply include this file after loading jQuery, and then you can do funky stuff like:
$('html').load('http://helixagent.com/todo/');
Note that this of course won’t load the embedded CSS and JS files. You’ll need to use an iframe for that:
$(function() {
$('body').append('<iframe src="http://www.helixagent.com/todo/" />');
});
Live example: http://jsbin.com/uruka
Here's an example using jQuery and iframe:
$(document).ready(function(){
$('#somediv').html("<iframe src='http://www.helixagent.com/todo/'></iframe>");
});
This should be placed inside the <head> tag of your page and it will load the entire site with all the js and css too into a div.
Have you looked at using Server Side Includes.
Related
I am loading a view using iframe.Now i wants to hide a div inside the iFrame using jQuery. But it shows $ is not defined.jQuery file is already included there.How can i do this?
<script type="text/javascript">
$(function(){
$("#wrap").hide();
});
</script>
jQuery has some major issues with iframes. You'll have to include a script inside your iframe and go from there.
What are you trying to use as a trigger to hide the div?
If it's at all possible I would suggest not using iframes for your website. Iframes come in handy when you're trying to embed a youtube video or something.
Goodmorning,
I've this situation:
I'm working with Wordpress and I'm trying to create an affiliate box for our affiliates. I've created it dynamically and you can see one example here
Values for the creation of the box are passed with $_GET and the box is created by a php function called before the_content() on the template page.
The box, if you load the page directly, works fine.
But I'm trying to load that specific div into another page and for test I'm trying to load it into a page of my same domain.
The page for the test is here
I'm using jQuery load() function for the loading, like this:
jQuery(document).ready(function(){
var valore = jQuery('#cm_aff_box_container').text();
jQuery('#cm_aff_box_container').empty().load('http://www.clubmagellano.it/affiliate-box/?value='+valore+' #cm_affiliate_box', function(){/*Other stuff here*/});
});
});
Unfortunately it won't load anything in the div. I've tried to load the page directly and it loads correctly despite the fact that also in this case my affiliate box is not loaded.
I've also read that the load() function won't work for other domains and I need that portability. How can I solve this problem?
==========UPDATE===========
I've resolved, and the box is loaded within my domain. The problem is, how can I load it on another domain?
==========UPDATE 2.0 ===========
Guys I've resolved putting this:
<?php header("Access-Control-Allow-Origin: *"); ?>
To the header.php file of the domain which create the box. It works perfectly!
Why not use an iframe? It's typically used to display ads in a page.
<iframe id="cm_affiliate_box"></iframe>
.
.
.
jQuery(document).ready(function(){
jQuery('#cm_affiliate_box').attr('src', 'http://www.clubmagellano.it/affiliate-box/?value='+valore+' #cm_affiliate_box');
});
If everyone is having this problem follow this solution:
Put this code to the header.php of your domain template, the domain which has to be loaded.
<?php header("Access-Control-Allow-Origin: *"); ?>
The load() jQuery function will recognize as trusted the website and will load the box. It's perfectly working!
If you don't want to allow all domains but only some, instead of '*' you could write the link of domain/s allowed to retrive the box.
I know we can get some path with <?php bloginfo('something');?> into php files, but is it some equivalent for javascript file loaded with the enqueue_script function ?
Did wordpress change some shortcode into those files ?
EDIT : I think I did not clearly express my needs. So i want to know if wordpress had some shortcode who, placed into a js file who is loaded with the enqueue method, will be replaced by the template path. Typically i need to make some ajax call form a .php file from my template and want to avoid hard linking file
No javascript files won't be parsed as php, and as such won't process any shortcodes or php.
Why not just make your links relative. Often I find subdomaining my dev copy, removes any problems when moving a site live and broken links.
You could cheat and link to a php file, which then passes header information as Javascript. Doesn't seem very elegant though. See here.
Or you could just declare the variable in a little bit of inline Javascript and pick it up in the external JS file.
<script type="text/javascript">
var siteURL= '<?php bloginfo('url');?>';
</script>
<script type="text/javascript" src="yourscript.js"></script>
Then in yourscript.js just reference the variable 'siteURL'
You have to register scripts using wp_register_script(). Then by placing wp_enqueue_script before wp_head() it will load them in for you. The idea of using wp_enqueue_script is that you don't need to enter them all in manually, and you can load other scripts depending on whether a certain script has been loaded.
I'm loading some content (NOT THE HTML headers or anything, just HTML formatted content from a PHP) via jquery .load() into a div.
It works, perfectly for everything BUT some Flash-based amCharts (www.amcharts.com) dynamically loaded with amCharts PHP, using swfObject. The file, loaded seperately, works and loads the Flash charts. When being loaded in using .load() the file seems to be loaded, but scripts not executed and swfObject not enacted.
Now, i'm not sure what code to give you here, so ill just give some stuff around it...
So, in header of main parent is the code listening for the nav click to load the content (which is our amcharts):-
$('a.leftNav').click(function() {
page = $(this).attr('page');
metID = $(this).attr('metID');
if($("#mainRight").is(":visible")) { $('#mainRight').hide(200); }
switch(page) {
case 'metrics': $("#mainRight").load("content.php?load=mets", { metID: '5000227' }); break;
}
$('#mainRight').show(300);
});
So that works. Loads the correct page and works executing the PHP as proved by going to the page content.php?load=mets. The code on that page generated by the PHP is:-
<div class="amChart" id="chart_views_div">
Chart loading ...
That should be the exchanged swfObject code, which I know (i've outputted to a text file the PHP's code generated) is working.
What happens with .load() and loaded swfObject and JS generally?
You need to call a function to initialise the swfObject replacement when jquery .load() has completed as i believe that swfObject would usually initialise on window.load.
something like this:
$("#mainRight").load("content.php?load=mets", function() {
// initialise swfObject here e.g.
swfobject.embedSWF("myContent.swf", "chart_views_div", "300", "120", "9.0.0");
});
Am Charts still uses swfobject 1.5
Swfobject 2.x offers much more IMHO amcharts should update to use the new version.
2.x has createswf which should be used in this case
I am having difficulty trying to get modernizer to run with codeigniter.
this is what I've done so far.
downloaded Modernizr and renamed the file modernizr-1.5.min.txt to modernizr-1.5.min.js
put the JavaScript file in the same directory as my header file is: apppath/views/tops/
included the file in my headings <script src="modernizr-1.5.min.js"></script>
included this in my HTML element <html class="no-js">
just to preserve my sanity I put the JavaScript file modernizr-1.5.min.js in my views directory and in the application directory.
I am getting absolutely zero response when I read my page source to see if the has been replaced with the elements that my browser covers the wave modernizr is supposed to work. I have tried this using Firefox and chrome as far as reading the source.
any suggestions? Thank you in advance
why would you put javascript files ito the view folder of your app? i would rather use this path "/media/javascripts/modernizr.js" and then <script src="/media/javascripts/modernizr.js"></script> link it like that. the view folder is only for templates. other thing is that you will never see the changes that javascript does to your page in the pagesource. because it only shows you what html the browser received. and javascript starts to work after the browser received the html. you need to install firebug to see the "live" dom.