hi all i stuck at a point in which i want to ma a multiple line text box to work just like a FACEBOOK text box . i.e. when a URL is pasted or typed (along with the text) it will it fetches the information from the page specifed by URL
well i found somthing at
This post
i want to know how to get URL in VAR in javascript
coz when i enter a url it fetches complete information how ever when i put another url it treat it as a text
Constantly search the text for a url via regex, possibly on a javascript event like onkeyup. Use ajax to load the page, and scrape out whatever info you want to display.
http://www.devguru.com/technologies/ecmascript/quickref/evhan_onkeyup.html
http://regexlib.com/Search.aspx?k=URL
Related
There is a website that I would like to pull data from, based on my user's search. The submit button and all inputs would be on my website and the results would be pulled from the website with the data, and have the results shown back on my website, for the user to see. The website that I would like to pull the data from has identical inputs.
Is it possible to connect input text boxes on one website to the input text boxes on another website and have the data requested appear back on my webpage?
Does anybody have any suggestions for doing this? Any ideas? I've never tried anything like this before, so if nothing else, it will be a good learning lesson.
You'll need a data scraper. PHP has Simple HTML DOM Parser: http://simplehtmldom.sourceforge.net/
Or you can use cURL: http://www.jacobward.co.uk/web-scraping-with-php-curl-part-1/
unless you have control over the server of the website you want to fetch data from, no you cannot.
or you can build yourself a HTML scraper .
To begin with, I'm fairly knowledgeable with both html5 and css3. Right now I'm trying to create a website that allows visitors to edit website content so that all visitors are able to see the edits. I know about contenteditable but this attribute does not last when the page is refreshed and no other visitors to see the edits. For example:
<p> Edit me please </p>
A visitor would be able to edit the element above by visiting the website and simply selecting and typing. Also I have heard that javascript, jquery, sql, and php can all allow visitors to edit website content but I don't know which is the best.
To sum up, if anyone knows how to allow visitors of a website to edit its' content it would be much appreciated to share their knowledge.
Create a database table (lets call it "strings") , and just define 2 columns - "string_identifier" and "string_value"
When you render the page, simply query the database to fetch the strings and their identifiers. Each editable element should have an attribute containing its identifier.
You can use jquery to capture the click event on all editable elements, and replace it with an input with that text.
Then assign an event handler to that input, so when the enter key is pressed, it sends a request to a php script (with the identifier and new string as data) on the server to update the database with the new string.
If you would like live updates to all other clients (no need to refresh), use jquery to continuously request a file on the server (endless loop), which will return a JSON object containing all the strings. Then go through and replace the text of all editable elements on the data with the new strings you have received from the server.
I am working on a project to scrape data from a website using DOM parsing. It can extract data from a particular website using that page url.
I want to add functionality to pass a php variable to that website's search box. and search that query. When a user manually enters a value in the website search box and presses search, the result comes out and we select that result. I want to do this programmatically.
How I can pass my php variable to a website search box and search on that website?
You will have to check and see how the form works - to which endpoint the data is posted. Then just do the same in your script and process the result (which might be servied in various different formats - JSON, HTML, XML etc.). Sometimes there might be added security, in particular if it's a .NET site that uses viewstate.
A somewhat straight forward suggestion would be to run a script on submission of the form that searches the text in each of the web pages in your working directory to find a match, then display a page with links to the found matches.
I will use PHP for my description of how this is done.
With this in mind, first learn how to read entire pages (i.e. webpages) into a string:
http://php.net/manual/en/function.file-get-contents.php
//YOU WILL HAVE TO LINE THIS UP WITH YOUR WORKING FILE NAMES
$home = file_get_contents('./home.php', FILE_USE_INCLUDE_PATH);
or I suppose you could just search for the actual webpage/URL like so:
$home = file_get_contents('http://www.example.com/');//IMAGINE THIS IS REALLY HOME.PHP
$homePageName = "home.php";//JUST HERE TO SHOW AN EXAMPLE
Example:
///YOUR FORM/INPUT BOX
<form action="search.php" method="post">
<input type="text" name="findMe" placeholder="Search...">
</form>
Now search.php
$search = $_POST['findMe'];
//$search = "example";//THIS WOULD WORK, BUT I WAS SHOWING HOW TO USE FORM
//IF WORD FOUND IN HOME PAGE
if (stripos($home, $search) !== false) {//USING EXAMPLE.COM TO SHOW IT WORKS
echo ''.$homePageName.'';
}
Then if you want to be simplistic and not use an array to store the found pages, take the same code above and use it for every page you want searched (i.e. home, about, products, etc..).
Now a user can search your site (or the pages you want indexed), to find all pages that have matching text. If you want specific keywords to be searched, just add them to the page metadata and the process I have described will still work as it searches everything that makes up the page.
<meta name="keywords" content="keyword1, keyword2, keyword3 " />
I have constructed an on-line What's On page supported by a mysql database table including a field to contain an event title. An admin page permits entries to be added, edited and deleted. More recently I was asked if web links could be embedded in the title field, and found that editing the field to include a link of the form:
Click <a class=hdg onclick="newWindow('http://www.address');"> HERE </a> to open web link
would do the trick and open the URL in a new window via the newWindow function.
Unfortunately any attempt to use the admin page to edit such a mysql record corrupts the admin page display, since the string is returned from the title field as the value of a text box, and the link text is then interpreted by the browser so that only part of the field displays in the box on the screen. The remainder of the string appears outside the box, which is confusing to a non-technical user.
A quick and dirty fix is to use Ctrl-A to select the whole of the text box contents when editing, and then type or paste the whole of the title content into the box, when it commits correctly to the database. However, if anybody knows of a way to code the javascript so that on the one hand it will function correctly as a web link and on the other hand can be edited via an HTML form, I would be glad to know. Ultimately I guess I'll re-construct the database to hold the actual URL separately and use php to build the javascript link, but meanwhile ?
Use htmlentities() to put the field value into the web page with all the HTML special characters replaced with entities, so they won't be interpreted:
echo '<textarea>' . htmlentities($value) . '</textarea>';
I have a javascript portfolio filter on a page that sorts logos by category, it assigns a category anchor link to the URL.
I'd like to use this anchor link URL to trigger an insertion of text. I can trigger the insertion of text via onclick with no problem using:
document.getElementById("insert-text").innerHTML
This works fine, but when you click on category logo & go to new page, I want to be able to hit "back" and still see the same results. The text insert disappears.
I was thinking something along these lines:
Get URL (with anchor)
if URL = certain category anchor
insert text
if URL = other category
insert other text
etc...
I think my logic is correct, but not sure of the syntax? Any suggestions would be greatly appreciated!
What you are asking to do is to save the state of a page so that when you go back to the page your browser returns to where you left off. This is what browsers use cookies for. Cookies are a set of key/value pairs that your browser stores and you can retrieve the values on. You could put a boolean in the cookie that signals whether your function has been triggered, on page load you can read the cookie and if it is set to true retrigger your function.
W3schools.com has a nice writeup on cookies to get you started.
This jsfiddle shows how you can expire the cookie logically.
document.cookie = 'ExpirationCookieTest=1; expires='+exp.toUTCString();