Full screen mode in php - php

I developed online exam for education company.I want to make my exam open on full screen mode.I tried several codes but don't work.Any help?
I disabled right click and f12.

You will need to use Javascript.
You can add a button or link that calls goFS() in it's href to trigger fullscreen in browser.
<script>
function goFS(){
if (fs.requestFullscreen) {
fs.requestFullscreen();
} else if (fs.webkitRequestFullscreen) {
fs.webkitRequestFullscreen();
} else if (fs.mozRequestFullScreen) {
fs.mozRequestFullScreen();
} else if (fs.msRequestFullscreen) {
fs.msRequestFullscreen();
}
}
</script>

Related

disable mouse middle click and right click on links wordpress

I want to disable mouse middle click and right click on links. Via Javascript or PHP.
Or, change the action of middle and right click to act as a simple left click
Is that even possible?
I tried some codes I've found over the internet. like this one:
<script type="text/javascript">
document.oncontextmenu=new Function('return false');
document.onmousedown=mainfn;
document.onclick=mainfn;
function mainfn(e){
e=(!e) ?window.event :e;
try{
if (e) {
e.returnValue = false;
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
if (e.preventDefault) {
e.preventDefault();
}
}
} catch (c) {alert(c); }
}
This should disable all mouse events. but still middle on links, works.

Send a Class to another page with Post

a DIV of one page (for example page01.php) flips 180° everytime that I click a specific button. In simple words, this button add or remove a class (rotator) to the DIV (rotate 180°) every time.
When I press another button to change the page (to page02.php) I need check if the DIV in page01.php has or not this class (rotator) and if this class it is applied I need to send it to the page02.php and apply the same class to another DIV to looks the same as the page01.php.
This is the Button in jQuery:
$(".btn-rotate").click(function() {
if ($("#box").hasClass("rotator")) {
$("#box").removeClass("rotator");
} else {
$("#box").addClass("rotator");
}
})
This is the DIV:
<div id="box" class="content-background bg-index">
This is the CSS of Rotator:
.rotator {
transform: rotate(180 deg);
transform - origin: center;
}
I Was thinking to use POST and GET of jQuery but i really don't know how to send the information.
Someone could have an idea?
Thanks!
Héctor
use local storage,
$(".btn-rotate").click(function(){
if ($("#box").hasClass("rotator")){
localStorage.removeItem('btn');
$("#box").removeClass("rotator");
} else {
localStorage.setItem('btn', 'rotator');
$("#box").addClass("rotator");
}
})
and in another page check if it's rotated or no
if (localStorage.getItem('btn') === 'rotator'){
$("#box").addClass("rotator");
} else {
$("#box").removeClass("rotator");
}
Assuming that you have the div with same id on both page page01.php and page02.php.
You can use Web Storage API to store certain values on browse for future uses as per your requirement. Here I have used sessionStorage. The sessionStorage object stores data for only one session (the data is deleted when the browser tab is closed). You can use localStorage property stores data with no expiration date.
On page page01.php
$(".btn-rotate").click(function() {
if ($("#box").hasClass("rotator")) {
$("#box").removeClass("rotator");
sessionStorage.removeItem("hasClass");
} else {
$("#box").addClass("rotator");
sessionStorage.setItem("hasClass", "yes");
}
})
on page page02.php
if (sessionStorage.hasClass) {
$("#box").addClass("rotator");
}
My Mistake, i forgot to put "=== 'rotator'. Thank you so much guys, works like a charm! Here is the final code:
page01.php:
$(".btn-rotate").click(function(){
if ($("#box").hasClass("rotator")){
localStorage.removeItem('rotated');
$("#box").removeClass("rotator");
} else {
$("#box").addClass("rotator");
localStorage.setItem('rotated','rotator');
}
})
Page 02.php:
get_localstorage();
function get_localstorage() {
if (localStorage.getItem("rotated") === 'rotator'){
$("#box").addClass("rotator");
}
};
Thanks again!!!

Don't display a button while file exists on server

I'm trying to display a download button on an HTML page only when a specific file on the web server is deleted. I thought I'd use a CSS display: none; then a PHP script with a while loop that'd look like this :
while (file_exists("/aaa/file.txt")) {
sleep(5);
}
//set display property of the invisibleLink class to block and continue
The thing is I don't know how to do this last step and every thread I've seen about modifying CSS with PHP doesn't work with my use case.
PHP executes before anything is displayed on the screen, so you are probably not going to be able to do that: the code would simply sleep for 5 and then continue with generating the rest of the html before displaying to the user.
What you might want to do instead is mark the button as display: none and then when the page is done loading have a js function that calls a php page that returns whether the file exists or not. Have the js function loop until the php page says the file is gone, then have the js function display the button and stop looping.
<button type="button" id="test_btn" style="display: none;">Download</button>
<script type="text/javascript">
$(document).ready(function () {
checkFile();
function checkFile() {
$.ajax({
url: '/path/to/file_checker.php',
type: 'GET',
success: function (data) {
if (data === "deleted") { // or whatever you want the response to be
$('#test_btn').show();
}
else {
checkFile(); // you can add a setTimeout if you don't want this running too often
}
}
});
}
}
</script>
Then your file checker php can be something similar to what you had:
if (file_exists("/aaa/file.txt")) {
echo "exists";
}
else {
echo "deleted";
}
Just build the button and hide it with a class like this:
<style>
.hidden{ display:none;}
</style>
<?php
if(!file_exists("path") ){ $class = "hidden" }
echo "<input type='button' class='$class' name='stuff'>woo</button>";
?>

How to make my simple alert window work

i'm currentrly coding in php and when i click a button the message should me Would you like to delete this entry?
This is where I'm currently at
<button onClick="alert('Sure to delete entry?')">Remove Entry</button>
And sure it works. But when I press "x" to close the alert window it still deletes the entry.
How can you make a popup window that has the "Cancel" opition?
I would really appreciate the help! :)
if (confirm("Your question")) {
// do things if OK
}
Use confirm
Click here for examples
You can do this using the following JavaScript code:
if (confirm('Sure to delete entry?') == true) {
//write your code here to delete
}
The HTML
<a href="delete.php?delete=<?php echo $row['guestbook_id'];?>"
onclick="return areYouSure()">Remove Entry</a>
And the JS
function areYouSure()
{
var con = window.confirm("Are You Sure?");
if(con)
{
return true;
}
else
{
return false;
}
}

PHP wont echo into Iframe in Webkit

hey guys I'm having a problem with an upload form I've made. It works in Firefox and IE but it wont work with Safari and Chrome so I assume it's a webkit problem.
First I run the php form and change the target to an iframe. Then once it's finished uploading I get PHP to echo a div iwth a statement true/false back into the iframe.
The problem i'm having is that PHP isn't echoing the statement into the iframe.
here's the code i've got:
in the php:
//do all the appropriate checks etc and if it's uploaded do the following
if ($success == true)
{
echo '<div id="result">success</div>';
} else {
echo '<div id="result">error</div>';
}
then in my javascript I do a few checks to see if the forms filled out etc and then if all is well I call submit() first and then I call iframeCheck()
function submit()
{
//change the target of the upload form to upload to the iframe.
$('#contactForm').attr('target','uploadIframe');
//submit the iframe
$('#contactForm').submit();
//fade in the sending message
$('#sendingMessage').fadeIn(200);
}
function iframeCheck()
{
//get the contents of iframe
var elem = $('#uploadIframe').contents().find('div#result');
var result = elem.html();
//if there's nothing in it, upload hasn't finished...
if ( elem.length <= 0)
{
//check it again in 2"
clearTimeout(timer);
var timer = setTimeout(iframeCheck, 2000);
} else if (result =='success'){
//if it contains a success message, display the success message
$('#sendingMessage').fadeOut(200);
$('#successMessage').fadeIn(500);
inputButton.removeAttr('disabled');
} else {
if (result == 'error')
{
//otherwise display the error message
$('#sendingMessage').fadeOut(200);
$('#failureMessage').fadeIn(500);
inputButton.removeAttr('disabled');
}
}
}
It works fine in ff and IE but as i said chrome and safari wont echo into the iframe.
Thanks for your help folks!
Is the iFrame URL the same domain as the general homepage? Perhaps it has something todo with cross domain policy.
Thanks heaps for your guys help. John it was a problem with my javascript. I was disabling the send button as soon as it was clicked. This worked fine except that webkit didn't like it so what I had to do was add onsubmit="document.getElementById('submitButton').disabled=true;" and that works fine now.
Cheers

Categories