how to take screenshot in php codeigniter? - javascript

Still i cant get any result can you help me?
i want take screenshot in my webpage. well i used code below showed:
<script>
window.ready = function () { alert("It's loaded!");
<?php
$img = imagegrabscreen();
imagepng($img, 'screenshot.png');
?> }
</script>
but it saved black image. what i do for it.?
i got code from as link below:
click this link:
http://www.codedevelopr.com/articles/image-screenshots-php/
finally help me that
code as PHP or script to take screenshot and save that image.
if anyone show a way of answer for this problem.
thanks in advance

According to this stackoverflow post, the fucntion will only work for XP and lower.
Please check your system preferences and maybe your logs for additional information.

Related

Jeditable not submitting properly

I've recently started leveraging jeditable for a project, and the documentation, which looks pretty straightforward does not appear to be submitting. The paragraph does become editable upon clicking, but when clicking 'Enter' the text does not change and no information is submitted to edit_test.php. Any and all help would be appreciated. I checked the JS console and error I see is:
POST http://localhost:8888/edit_test.php 500 (Internal Server Error)
as well as:
jquery-3.5.1.min.js:2 XHR failed loading: POST "http://localhost:8888/edit_test.php"
Code below:
Relevant HTML
<p id="edit_test">Please edit me!</p>
JS
$(document).ready(function() {
$('#edit_test').editable('edit_test.php');
});
edit_test.php is as follows:
<?php
$edit = 'Do not edit me!';
if ($_POST['id'])
{
$edit = $_POST['value'];
}
echo $edit;
?>
Thanks in advance!
I figured this out, and, though I think I probably asked the question poorly, I thought I'd post in case this helps anyone in the future.
jeditable references a "save.php" in its documentation, but never provides an example of what a basic "save.php" should contain. In my example, I simply needed the server page to display the posted 'value' parameter. In other words:
<?php
if ($_POST['id'])
{
echo $_POST['value'];
}
?>
Easy peasy.

How to fill a div that is loaded from another html page

I'm trying to load a div from another html page, then fill it with values from my main html page.
My div is correctly loaded and displayed, but it seems like it doesn't want to fill up. Here's what I have so far :
$("#valider").click(function() {
$("#ag_pub_panneau_detail_html").load( "https://tc610/ag_pub_collecte/Ag_pub_panneau_detail.html #ag_pub_panneau_detail_master_div");
$("#ag_pub_panneau_detail_html").show();
});
So when I click on the "valider" button, my div is loaded and displayed, so far so good.
And here's where I'm struggling, I tried this :
if ($('ag_pub_panneau_detail_html').is(':visible')) {
$('#ag_pub_panneau_entityid').val($('#ag_id_panneau').val());
}
but the div stays blank. So I tried this instead :
$("#valider").click(function() {
$("#ag_pub_panneau_detail_html").load( "https://tc610/ag_pub_collecte/Ag_pub_panneau_detail.html #ag_pub_panneau_detail_master_div", fillDiv());
$("#ag_pub_panneau_detail_html").show();
});
function fillDiv(){
$('#ag_pub_panneau_entityid').val($('#ag_id_panneau').val());
}
But I get the same result. So I tried something else :
$("#valider").click(function() {
$("#ag_pub_panneau_detail_html").load( "https://tc610/ag_pub_collecte/Ag_pub_panneau_detail.html #ag_pub_panneau_detail_master_div");
$("#ag_pub_panneau_detail_html").show();
$('#ag_pub_panneau_entityid').val($('#ag_id_panneau').val());
});
I was thinking that since the .show() works well, I could add my line below it, but it doesn't seem to execute either.
So I used to think that this line :
$('#ag_pub_panneau_entityid').val($('#ag_id_panneau').val());
Was wrong but when I execute it from the Chrome console, the field is correctly filled... I don't know what's happening, and I'm out of ideas for my issue.
Is there something I'm doing wrong ?
I can provide more code/details if you want to, just ask me
Any help would be greatly appreciated !
I managed to get it working, what I did is that I created a js file for the Ag_pub_panneau_detail.html page (the one that is loaded) in which I just wrote :
$(document).ready(function()
{
$('#ag_pub_panneau_entityid').val(localStorage.getItem("ag_pub_panneau_entityid"));
});
And now it works like a charm :)
By the way, can I know why I have those downvotes on my question ?
Anyway thanks for your help !

JSON output on HTML page

I want to display a JSON object on a html page. When I enter
productArray[0][0].xyz
into the Firefox console then I get a value back.
Question:
How can I display the value which is stored in this variable on a HTML page?
I have tried this (didn't work):
<div id="test">
<script>
window.onload = function()
{
var out = productArray[0][0].xyz;
document.getElementById("test").innerHTML = out;
}
</script>
Since it's working in console in browser, I guess it's a timing problem. You're probably trying to use the value in the json before the json data is loaded and ready to use.
Assuming you're running an xhttp request or ajax call or something you'll have to run the code AFTER data is loaded. Which often means running it inside successmethod.
Maybe this post and answer helps you locate the problem? NB: This uses Ajax, so feel free to update your post with some more information so we can help you with your solution / technologies.
Ajax success function
Assuming that missing div close tag is a typo most probably the productArray is not populated by the time your code executes. Can you post a more detailed snippet ?
var out = "your value";//productArray[0][0].xyz commented to show you running code uncomment it when you use this in you code. ;
document.getElementById("test").innerHTML = out;
<div id='test'></div>
You actually forgot to close the DIV tag.

Counting the number div loaded from external php file

I have two php files, child.php and parent.php. Child.php generates div. Now, the parent.php calls child.php to be loaded in <div id='divContainer'>. Now, I need to count the div inside the divContainer. Is it possible?
I tried something like this:
$(document).ready(function () {
var total_record = $('#divContainer > div').length;
alert(total_record);
});
But it's not working. Even an empty alert is not popping out.
Can someone here, help me on this? THank you!
There's a syntax error:
)};
Should be:
});
Often if you are not getting any output/result at all when expected, it is down to a syntax error which will cause the browser to be unable to parse and execute the code. For future debugging, use the error console as this normally points out any errors with a decent description of the problem.

Firefox- Extension - How to make a sidebar

Can anybody tell me how to make a sidebar. There is nothing about sidebar in the XUL reference. I referred some old codes. But, I can't get where to edit. In those codes I have to create jar files frequently which annoys a lot. Can anybody show me a guidance, just a simple code to add a listbox in sidebar?
Edit:
This code works. I edited the code in "emptysidebar.xul". But it didn't work.
Any solution to add elements in sidebar is welcomed.
I didnt even dreamt that the solution will be this much simple. This is the solution.
var sidebarWindow = document.getElementById("sidebar").contentWindow;
if(sidebarWindow)
{
sidebarWindow.location = "chrome://custombutton/content/login.xul";
// your xul location
}
else
{
alert("sidebar window is not null");
}

Categories

Resources