Display Particular Div on my another website - php

I two website abc.com content div with id 'abc' and another website def.com. content div with id 'def'. The Qns is how can I display content of div having id='abc' into div id='def'.

Well you need to scrape content of abc.com, then search dom element to find div "abc", fetch its content and put it in def div of another site.
for scraping use http://simplehtmldom.sourceforge.net/

That can not be possible , reason is to read content you need to call some ajax request. And ajax never works between cross domain.

The thing you are trying to do is called webpage scrapping. You can not do it using client side Javascript alone as it gives cross-domain error. But you can use node.js - server side javascript.
http://net.tutsplus.com/tutorials/javascript-ajax/web-scraping-with-node-js/

Related

populating iframe with content from POST

I need to display content that was posted from the previous page within iframe. Is it possible?
The content will have HTML tags.
The reason why I need iframe, because it will also have reference to CSS. If I just echo it on page, then it will make problems with CSS style of the main webpage. The only sollution I have found is to use iframe.
Why not just correct your CSS?
FWIW, I don't think you are able to POST data to anything inside an iFrame, especially if you don't have control over the iFrame content.
Iframes link to a URL.
So if you can save the post data into a file on your server and then use ajax or refresh the page to inject the url to that file on the iframe, then you will be sorted.

How do you do dynamic refresh of a single div tab using php/ajax and have the content actually change the local html on the page

How do you do dynamic refresh of a single div tab using php/ajax and have the content actually change the local html on the page (so that it is changed when you go to ‘view source’ in a browser) instead of just putting the change in a JavaScript object? I am trying to design a webpage that loads search results without refreshing the entire page. I use a simple hash followed by a GET/query string request to determine what content to load. This gets passed to a JavaScript XMLHttpRequest, then to some php which picks up the GET and passes it to a SOAP service and finally echo’s the SOAP results back to the XMLHttpRequest to get displayed in a document.getElementById div change. This works fine for usual display in conventional browsers. However I am concerned that search bots and screen readers are not going to recognize the majority of the content that shows in browsers because it is all contained within a client side JavaScript object.
So, I guess my first question is: is this a valid concern? If it is, is there a work around?
Thanks!
AJAX content is very hard to get indexed. Google has webmaster guidelines for AJAX. This should get you started in the right direction on getting your content indexed.
I'm inexperienced with search engine behavior but as far as i know the best option is to load the full content of your div on a php page, when the page load you can include that page inside the div, and then start using js/jquery to refresh that every so many seconds.
this way when a search bot gets on the site it will see the current content, and users will see it update.
updating the div box can be done quite easy using ajax function and jquery.

Load a div from external source

I am trying to load a div from another domain and display it on my site. An <iframe> will not work as the content is dynamically sized and I don't wish to render the entire page, just the content of <div id="content-article">
I have attempted to follow the guide from: http://frinity.blogspot.com/2008/06/load-remote-content-into-div-element.html however after reading the comments it appears to only work for external pages on the same domain.
I don't really care how it is done; php, jquery, ajax or what have you I just don't want to upload the same content to two different domains.
Is there any way to do this?
You can't when it should fetch it from external URL. Perhaps you can create a proxy or so and do a jquery.get?
You could use PHP's DomDocument to parse the HTML of the page that has the div and extract the div you want and then put it into your own content.
What is the URL with the div you want to grab? (Maybe we could write some code to help you pull it out.)

How do I push website content down and insert ad at the top?

Can someone tell me how to write code that pushes the content of a finished webpage down half an inch or so, then loads an ad across the top of the page, like this example:
http://abcnews.go.com/International/hideouts-sacred-spaces-experts-baffled-mysterious-underground-chambers/story?id=14136379
(example may no longer be showing this ad/function)
The entire page loads, then gets pushed down, then the ad loads at the top of the page. My code for this would be at/near the bottom of my clients html.
The ad content will come from a different server.
The same code would ideally work with all/most finished websites instead of being specifically tailored for each one.
Thanks for any and all help.
I suppose you implement your ads in your HTML by using a static code (eg. when you're using Google Ads). When you put this code on top of your page, it'll show the ad on top of your page. Optionally, you can style it a bit so it's centered.
Since you load your ads from a different server, I don't see any reason why the HTML-code behind those ads is dynamic (I don't know if it is?). Your ad-provider will take care of showing the ads in a random-order.
If you'd looked at the source of the page you'd see this this is achieved using JavaScript, not PHP. If you want it to happen (seemingly) after the page loads you need to write some php to inculde the html/JavaScript/images whatever for the ad, then some JavaScript to dispay it once the page has finished loading. Or use AJAX to dynamically modify the DOM.
Check out the jQuery JavaScript framework.
I would prefer to use a front-end code like jquery or normal javascript, and prepend your ad to the body.
OR
If you want to do it with a server-side language. You can add the server variable just after the opening body tag, and populate the html to the variable via server-side code.
See my example:
Gray : body tag
Green : your website
Red : the ad section
If you don't have a wrapper container around your div, add one. And use the methods I mentioned above to prepend the ad to your site.

target a specific page in iframe

I'm running the CMS indexhibit, indexhibit uses an iframe to load it's content.
http://www.therussianfrostfarmers.com/
My homepage has WordPress loaded into this iframe, which works ok, i've got some scrollbar issues, but that another problem.
Currently, when ppl find a WP post through there search engine, the user is redirected to the homepage, i need to do this otherwise the user would only be able to view the WP content and not the rest of the site aswell.
e.g ;
http://www.therussianfrostfarmers.com/oldspeak/?p=480
What i need to do is to split the querystring, and send an 'id' into the iframe, which inturn would load the appropriate WP page inside the iframe.
I'm not sure where to start, Would i use PHP to split the querystring? and Javascript to target some iframe properties?
....any help would be much appreciated
thanks Cam
You might not have to split the query string. You could just use PHP to get the value of that GET variable, for instance:
$_GET["p"]
would equal 480 for the request http://www.therussianfrostfarmers.com/oldspeak/?p=480
then, you could just use the properties of the iFrame to change what it requests. I believe that the URL that the iFrame seeks is set in an HTML attribute. So you could just set the iframe URL to
http://www.yourwordpresssite.com/?p=<?php echo $_GET["p"]; ?>
Or a similar method.

Categories