Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Like "Facebook", I want to disable all of my website content if "JavaScript" is disabled. When JavaScript is disabled Facebook only shows a message .
"JavaScript Required We're sorry, but Facebook doesn't work properly
without JavaScript enabled. If you can't enable JavaScript try
visiting the mobile-optimized website. "
Now what i'm trying to do is, if anyone disable JavaScript, they will only be able to show a message, nothing else.
How can I do that?
this will redirect to javascriptNotEnabled.php
<noscript><h3> You must have JavaScript enabled in order to use this order form. Please
enable JavaScript and then reload this page in order to continue. </h3>
<meta HTTP-EQUIV="refresh" content=0;url="javascriptNotEnabled.php"></noscript>
How??
What you should do is create a div that fills the entire page using html and css, then right after window.onload, remove that div
<div id="nojs" style="width:100%;height:100%;position:fixed; background-color:white;">
<h1>Enable JavaScript!</h1>
</div>
<script>
window.onload = function () {
document.getElementById('nojs').parentElement.removeChild(document.getElementById('nojs'));
}
</script>
noscript doesn't can't disable the whole page as far as I am concerned
Fiddle while JSFiddle doesn't work without JavaScript, the code still is an example
PHP is a server-side and can't analyze such settings of your browser.
But, You can just use javascript <noscript> tag to do this
The <noscript> tag defines an alternate content for users that have disabled scripts in their browser or have a browser that doesn't support script.
Read more about <noscript> from the w3 resource here
<script>
document.write("Hello World!")
</script>
<noscript>Please enable JavaScript!</noscript>
load the site contents via javascript.
Your page should look like:
<html>
<body>JavaScript Required We're sorry, but Facebook doesn't work properly without JavaScript enabled. If you can't enable JavaScript try visiting the mobile-optimized website.</body>
<script>
document.getElementByTagName("body").innerHTML = "";
</script>
<script src="loadPage.js"></script>
</html>
Related
I searched for other answers but mine seems the simplest!
My web builder lets me insert Javascript, HTML or CSS snippets into the <head> and <body> source code. It seems these snippets affect all website pages.
I inserted AddThis 'inline share buttons' within the <body>:
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5ebdd74910cfe8a0"></script>
For activating the buttons, I added the next code in a single web page (drag-and-drop html code tool):
<div class="addthis_inline_share_toolbox_xa65"></div>
But the share buttons are not shown on that page: http://builder.ferozo.com/reparando-todo/#!/-testing/
I've tried adding both code snippets together into the same web page but no results. It doesn't seem to be a problem related to browsers blocking an unsafe widget due to a lack of a SSL Certificate.
Any idea of what could be the problem?
google chrome console , has a problem in show javascript code
Does not display my codes
Even in debugger , after refresh page or whatever
js script in my page start with : <script type="text/javascript">
my file is php and server is xampp
Syeed Masoud Tayefi indeed you need to add the src to the tag, otherwise the browser not only won't show you the file, neither read it and hence not perform any fuction that has been wrote down. Here is how I do it myself in order to check and debug if need it
<body>
<div> ...whatever goes in here...</div>
<script src="./functions.js"></script>
</body>
Hope my answer help a bit to clarify your question. As You didn't leave any of your code, I can't speak about the unclosed issues, if any.
I have developed a webpage that requires very little javascript. Although I still need to make the site work for all users. So first I ask, is there a way to hid a single div when javascript is disabled. If this is not possible how would I go about loading a different version of the page that doesn't have the div in it
Use the noscript tag
http://www.w3schools.com/tags/tag_noscript.asp
<script>
document.write("Hello World!")
</script>
<noscript>Your browser does not support JavaScript!</noscript>
I have an iframe on my webpage that contains a linked qwebirc webchat that automatically logs visitors into irc with a temporary nick so all page visitors can instantly chat with each other.
I need to switch from qwebirc to kiwi irc, but it doesn't support autoconnecting.
** It will be connecting to our own irc server and I understand the risk of automatically joining visitors.
Since we cannot install a custom kiwi irc installation to our web server and customize it to autojoin, I know that I'll need to use a jquery function to automatically click the start button on the linked widget in the iframe.
Here is an example of what I'm working with:
<html>
<head>
<title></title>
</head>
<body bgcolor="#000000" link="#FFFFFF" vlink="#FF0000" alink="#FFA500">
<center>
<font face="tahoma" color="#FFFFFF">The "Start..." button below needs to be automatically clicked on page visit.</font>
<br><br>
<iframe src="https://kiwiirc.com/client/irc.MYCHATSERVER.net:6660/?nick=TESTNAME-?&theme=mini#TESTCHANNEL" height="400" width="400"></iframe>
</center>
</body>
</html>
(our server and channel have been renamed for this post, so it shouldn't actually connect)
I know that the function we need to use is:
$(document).ready(function(){
$('#some-id').trigger('click');
});
but I can't seem to find the id of the button.. the only thing I can find is the following line:
<button type="submit">Start...</button>
..that I found here: http://i.imgur.com/05IFHSZ.jpg
I'm not very good with javascript, but am a very willing learner and have a bit of a problem to solve. Any advice on how to incorporate the jquery code is greatly appreciated.
Thanks!!!
You will not be able to interact with elements inside the iframe using scripts from the parent document, or vice versa. This is a security measure and not something you can circumvent.
The same-origin policy restricts how a document or script loaded from
one origin can interact with a resource from another origin.
See Same-origin policy
I took a look at the IRC page and noticed that the button that needs to be clicked—<button type="submit">Start...</button>—is always the first button on the page. Therefore, you can use the following code to click it:
$("button").first().click()
note:
Concerning what pwdst said, you cannot script cross-domain (by default). However, this jQuery library may very well be worth looking into.
How can i create web page with out address/menu and tool bar.
I want the page to load without address/menu and tool bar.
Can someone please help to create webpage in asp.net or html using javascript.
I tried using javascript by using following code, but this warns that this page is closing i dont warning to be display.
a.htm
<head>
<script type="text/javascript">
function init()
{
var window_dimensions = "toolbars=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=yes";
window.opener=self;
window.close();
window.open("b.htm","_blank", window_dimensions);
window.moveTo(0,0);
window.resizeTo(screen.width,screen.height-100);
}
</script>
</head>
<body onload="init()">
These are standard security restrictions today, put there for good reason. Don't try to work-around them. If you think you have a need to do so, I'd re-review your requirements and reasons for doing so. If it is truly a need, you may need to consider a custom desktop (non-web-browser) application. This could still be a HTML-based application, but a custom desktop "browser" would be required.
See also: How to pop out a Firefox window without an address bar or status? (This includes excellent details for a custom desktop "browser", and follows the above recommendation.)