Folks,
I am new to js and this I am having trouble capturing and taking a screenshot of a remote website. Can someone point me in the right direction
I keep getting this error:
Uncaught TypeError: Object [object Object] has no method 'html2canvas' index.php:4201
capture index.php:4201
onclick
My code is index.php
<html>
<head>
<title>Hawk-Eye: Have a look at what others are upto</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://localhost/Hawk-eye/html2canvas.js"></script>
<script type="text/javascript" src="http://localhost/Hawk- eye/jquery.plugin.html2canvas.js"></script>
</head>
<body>
<div id="target">
<?php
$homepage= file_get_contents('http://www.yahoo.com');
echo $homepage;
?>
</div>
<form method="POST" enctype="multipart/form-data" action="save.php" id="myForm">
<input type="hidden" name="img_val" id="img_val" value="" />
</form>
<script type="text/javascript">
function capture() {
$('#target').html2canvas({
onrendered: function (canvas) {
//Set hidden field's value to image data (base-64 string)
$('#img_val').val(canvas.toDataURL("image/png"));
//Submit the form manually
document.getElementById("myForm").submit();
}
});
}
</script>
<input type="submit" value="Take Screenshot" onclick="capture();" />
</body>
</html>
Download html4canvas and import it as
<script type="text/javascript" src="html2canvas.js?rev032"></script>
Related
I am new to web development, and have encountered a problem with jquery and php. Having trouble calling a php file with jquery through xampp using a simple GET and POST a http request. Any help would be greatly appreciated. Thank you!
<?php
$name=$_POST['name'];
if($_POST['name']!=""){
echo 'Shalom'.$name;
}else{
echo 'Enter name';
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<input type="text" id="name" placeholder="Name"/>
<button id="button">Submit</button>
<div class="response"></div>
<script type="text/javascript">
$('#button').click(function(){
var name=$('#name').val();
$.post('jquery post http request.php',{name:name},function(response,status,xhr){
$('.response').text(response);
});
});
</script>
</body>
</html>
jQuery tokeninput returns null value. when I submit the form the $_POST[] array is empty.
In the demo when I click submit button it alert :"would submit:" and the values. I did the same in mine and it alert : "would submit: undefined".
my form.html :
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.tokeninput.js"></script>
<link rel="stylesheet" href="token-input-facebook.css" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
$("input[type=button]").click(function () {
alert("Would submit: " + $(this).siblings("input[type=text]").val());
});
});
</script>
</head>
<body>
<form action="process.php" method="post">
<label for="title" class="control-label col-sm-2">Title(s) :</label>
<input name="title" id="title" class="form-control">
<input type="button" value="Submit" />
<script type="text/javascript">
$(document).ready(function() {
$("#title").tokenInput("gethint.php", {
theme: "facebook",
hintText: "Begin typing title ...",
noResultsText: "No titlesfound",
propertyToSearch: "title",
tokenValue: "'id'",
tokenDelimiter: ","
});
});
</script>
</form>
</body>
</html>
process.php :
<?php
$titles = $_POST["title"];
?>
<html>
<body>
<?php
print_r($names);
?>
</body>
</html>
There are no input[type=text]elements in your html as specified here:
alert("Would submit: " + $(this).siblings("input[type=text]").val());
Change your html to:
<input type="text" name="title" id="title" class="form-control">
I'm trying to use TinyMCE 4.1.4 in my php page but I didn't succeed, I did include the path of TinyMCE but when I execute the script it gives me simple text area, I don't know what's the problem.
<html>
<head>
<script type="text/javascript" src="js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea"
});
</script>
</head>
<body>
<form method="post">
<textarea ></textarea>
</form>
</body>
</html>
Works fine here jsFiddle Demo
Try to include your code inside ready function before that include jQuery library as well so your full code should be :
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://tinymce.cachefly.net/4.1/tinymce.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
tinymce.init({
selector: "textarea"
});
});
</script>
</head>
<body>
<form method="post">
<textarea ></textarea>
</form>
</body>
</html>
It's because you're doing all the JS before the DOM has fully loaded.
<body>
<form method="post">
<textarea ></textarea>
</form>
<script type="text/javascript" src="js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea"
});
</script>
</body>
</html>
hi im trying to integrate a jquery datepicker to my codeigniter project.. the problem is that i cant get it to work .. my source code came from http://view.jquery.com/tags/ui/latest/demos/functional/#ui.datepicker
ok heres my code:
view:
<srcipt>
$("#formatted").datepicker({
dateFormat: $.datepicker.ISO_8601,
showOn: "both",
buttonImage: "templates/images/calendar.gif",
buttonImageOnly: true
});
</script>
<form action="add" method="post" class="form label-inline uniform" />
<input type="text" size="30" value="" id="formatted"/>
<input type="submit" class="btn btn-grey" value="Add User"/>
</form>
<script src="/assets/js/jquery/jquery-1.5.2.min.js"></script>
EDIT
i already added all the js sources but its still not working
<script src="/assets/js/jquery/jquery-1.5.2.min.js"></script>
<script src="/assets/js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
<script src="/assets/js/misc/excanvas.min.js"></script>
<script src="/assets/js/jquery/facebox.js"></script>
<script src="/assets/js/jquery/jquery.visualize.js"></script>
<script src="/assets/js/jquery/jquery.dataTables.min.js"></script>
<script src="/assets/js/jquery/jquery.tablesorter.min.js"></script>
<script src="/assets/js/jquery/jquery.uniform.min.js"></script>
<script src="/assets/js/jquery/jquery.placeholder.min.js"></script>
<script src="/assets/js/widgets.js"></script>
<script src="/assets/js/dashboard.js"></script>
EDIT
created a sample view page for datepicker.. still not working even the link for the image is not working.
<html>
<head>
<script src="/assets/js/jquery/jquery-1.5.2.min.js"></script>
<script src="/assets/js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
<script src="/assets/js/misc/excanvas.min.js"></script>
<script src="/assets/js/jquery/facebox.js"></script>
<script src="/assets/js/jquery/jquery.visualize.js"></script>
<script src="/assets/js/jquery/jquery.dataTables.min.js"></script>
<script src="/assets/js/jquery/jquery.tablesorter.min.js"></script>
<script src="/assets/js/jquery/jquery.uniform.min.js"></script>
<script src="/assets/js/jquery/jquery.placeholder.min.js"></script>
<script src="/assets/js/widgets.js"></script>
<script src="/assets/js/dashboard.js"></script>
</head>
<body>
<script>
$("#formatted").datepicker({
dateFormat: $.datepicker.ISO_8601,
showOn: "both",
buttonImage: "http://pgoadmin.com/assets/images/calendar.gif",
buttonImageOnly: true
});
</script>
<form>
<input type="text" size="30" value="" id="formatted"/>
</form>
</body>
</html>
You need to load in jQuery UI to use the date picker
https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.js
Dont forget the images and CSS as well:
http://jqueryui.com/download
You need to include jquery before you start using it. Try moving the JS code below the jquery tag.
And as Wes says, you need to include jquery UI datepicker component as well.
Also, and this maybe a typo, your tag says "sricpt" instead of "script".
and don't forget to add base_url(); to your js paths
e.g.
<script src="<?php echo base_url(); ?>assets/js/dashboard.js"></script>
test.html
<html>
<!--
Please see the full php-ajax tutorial at http://www.php-learn-it.com/tutorials/starting_with_php_and_ajax.html
If you found this tutorial useful, i would apprciate a link back to this tutorial.
Visit http://www.php-learn-it.com for more php and ajax tutrials
-->
<title>php-learn-it.com - php ajax form submit</title>
<head>
<script type="text/javascript" src="prototype.js"></script>
<script>
function sendRequest() {
new Ajax.Request("test.php",
{
method: 'post',
postBody: 'name='+ $F('name'),
onComplete: showResponse
});
}
function showResponse(req){
$('show').innerHTML= req.responseText;
}
</script>
</head>
<body>
<form id="test" onSubmit="return false;">
<input type="hidden" name="name" id="name" value="value">
<input type="hidden" name="somethingElse" value="test" value="submit" onClick="sendRequest()">
</form>
Post!
<div id="show"></div>
<br/><br/>
</body>
</html>
<?php
/*
* Please see the full php-ajax tutorial at http://www.php-learn-it.com/tutorials/starting_with_php_and_ajax.html
* If you found this tutorial useful, i would apprciate a link back to this tutorial.
* Visit http://www.php-learn-it.com for more php and ajax tutrials
*/
if($_POST["name"] == "")
echo "name is empty";
else
echo "you typed ".$_POST["name"];
?>
Where is the wrong in form thanks.
A few things are wrong here:
You have an onclick on a hidden form element
The Post! anchor onclick isn't submitting anything
Suggested changes:
<head>
<script type="text/javascript" src="prototype.js"></script>
<script>
function showResponse(req){
$('show').innerHTML = req.responseText;
}
</script>
</head>
<body>
<form id="test" name="test" action="test.php">
<input type="hidden" name="name" id="name" value="cats" />
<input type="hidden" name="somethingElse" value="test" />
</form>
Post!
<div id="show"></div>
</body>
form id="test" and no name
and yet :
a href="#" onclick="myForm.submit()"
just for starters.