Whenever I try this, I get the following error in the Firefox console:
[09:20:30.028] The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol.
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>this is a title</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script>
function showAnswer(){
document.getElementById("ans").innerHTML="This is the answer";
}
</script>
</head>
<body>
<div id="q">
This is a question?
<button action="showAnswer()">Show Answer</button>
</div>
<div id="ans">
</div>
</body>
</html>
Sorry if this is a stupid question, I'm kinda new to this.
You only need;
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
should fix your problem.
Get rid of
<meta content="utf-8" http-equiv="encoding">
You just want...
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
This is also wrong...
<button action="showAnswer()">Show Answer</button>
Probably want...
<button type="button" onclick="showAnswer()">Show Answer</button>
See http://jsfiddle.net/5Qtq2/
Related
I am a web developer and using Atom as text editor but I always have to change some autocomplete suggestions.
For example when I type html and pres tab it gives me this
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
This result is not actually what so I manually change it like this
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=11">
<meta name="author" content="Your name">
<meta name="description" content="Brief description">
<link rel="manifest" href="/manifest.json">
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<meta name="theme-color" content="#00FFF0">
<link href="style.css" rel="stylesheet">
<title>Title</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
So I did a research and everybody solves this kind of similar issues with snippets I am not asking how can I do it with snippet. I already know it. I want to change these codes from editor's current location. Possibly it locates somewhere in ~/AppData/Local/atom but I haven't found it yet. I want to reach that file and change related suggestions from there.
This is not only for html suggestion I also want to remove something from PHP suggestion and add some for JavaScript suggestion.
Any idea how this system works and how to do it ?
Thanks.
This question already has answers here:
avoid to escape a special characters in javascript
(5 answers)
Closed 1 year ago.
I want my text to be treated literally. When I write for example "\nraw\t" I want it to be displayed exactly like this - "\nraw\t", not "raw" when I use textContent or createTextNode.
Here is an exemplary HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raw, ok</title>
</head>
<body>
<div id="first"></div>
<div id="second">\nRaw\t</div>
<script>
document.querySelector("#first").textContent = "\nRaw\t";
</script>
</body>
</html>
In div with id "first" I get "Raw" without "\n" and "\t". (This is the unwanted result.)
I'm satisfied with what String.raw`\nRaw\t` returns, but unfortunately, this method is not supported by a few browsers including Opera, so I cannot use it. Any suggestions would be great.
EDIT:
Okay, maybe I should have given more details about it and not try to simplify my actual problem. The thing is - it will not always be "\nRaw\t". It can be anything my user provides in a form - so text with no special characters, text with only special characters, anything they want, so I need this solution to be flexible.
If you don't want the string to have the two quotes at the beginning and end like the answer here: Javascript - How to show escape characters in a string?, just use the splice method to cut them away.
const str = JSON.stringify("\nRaw\t")
const cutStr = str.slice(1,str.length-1)
document.querySelector("#p").innerText = cutStr;
<div id="p"><div>
You can use JSON.stringify and then remove the first and last characters (the quotes) using String#slice.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raw, ok</title>
</head>
<body>
<div id="first"></div>
<div id="second">\nRaw\t</div>
<script>
document.querySelector("#first").textContent = JSON.stringify("\nRaw\t").slice(1, -1);
</script>
</body>
</html>
You can escape with a backslash \
Or use JSON.stringify with slice to remove quotes as suggested by others.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raw, ok</title>
</head>
<body>
<div id="first"></div>
<div id="second">\nRaw\t</div>
<script>
document.querySelector("#first").textContent = JSON.stringify("\nRaw\t").slice(1, -1);
</script>
</body>
</html>
I'm just kind of learning Javascript was following this exercise but it's not working and I don't understand. The page should read Some more text when loaded. But it's only show Some text from the paragraph. It not changing over with the getElementById like it should. Any tips?
<!doctype html>
<html>
<head>
<title>Learning Javascript</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<p id="text">Some text</p>
<script type="text/javascript">
// This is a comment
/* Multi line comment
*/
document.getElementById{"text"}.innerHTML="Some more text";
</script>
</body>
</html>
document.getElementById("text").innerHTML="Some more text";
You have the wrong type of brackets. Use ()
You're using curly braces where you should be using parentheses.
Try this:
document.getElementById("text").innerHTML="Some more text";
I'm trying to keep all the files Edge generates separate from my main files.
This is the html in the file it publishes:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>Untitled</title>
<!--Adobe Edge Runtime-->
<script type="text/javascript" charset="utf-8" src="anim_edgePreload.js"></script>
<style>
.edgeLoad-EDGE-20819118 { visibility:hidden; }
</style>
<!--Adobe Edge Runtime End-->
</head>
<body style="margin:0;padding:0;">
<div id="Stage" class="EDGE-20819118">
</div>
</body>
</html>
I copied the code over to an html file outside the animation folder containing all the generated files and changed the directory of the JS file it's referring to.
anim_edgePreload.js --> edgeAnimation/anim_edgePreload.js
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>Untitled</title>
<!--Adobe Edge Runtime-->
<script type="text/javascript" charset="utf-8" src="edgeAnimation/anim_edgePreload.js"></script>
<style>
.edgeLoad-EDGE-20819118 { visibility:hidden; }
</style>
<!--Adobe Edge Runtime End-->
</head>
<body style="margin:0;padding:0;">
<div id="Stage" class="EDGE-20819118">
</div>
</body>
</html>
The animation no longer appears on the page, any idea why?
I get this error in Firebug after a few seconds:
TypeError: AdobeEdge.okToLaunchComposition is not a function
function edgeCallback(a){htFallbacks[a]&&(a=htFallbacks[a]);AdobeEdge.preload.got[a]=!0;if(a==AdobeEdge.preload.last)AdobeEdge.okToLaunchComposition(compId),AdobeEdge.preload.busy=!1,AdobeEdge.preload.q.length>0&&(a=AdobeEdge.preload.q.pop(),AdobeEdge.requestResources(a.files,a.callback))}
My issue was displaying the animation in a div on another page. Any attempt to load the animation explicitly failed. I succeeded in resolving this issue by using the HTML object tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Banner</title>
</head>
<body style="margin:0;padding:0;">
<object data="animations/liferay/liferay-00.html" style="height:175px; width:100%"></object>
</body>
</html>
Do note I did NOT change any of my URL paths. All I did was point to the publish folder.
So if you still encounter issues try re-publishing.
Update:
Additional solution provided by Wayne Barron:
http://youtu.be/RQKqlpCkrjs
I have some Dijit Tabs, and in those tabs I have some Dojo Text boxes and Fields. Some of my Dojo Tabs load when the page is loaded, and some load only when clicked on.
My issue is that I cant get the Tabs that load only when clicked, to work with the Dojo modules.
Its hard to explain, so I made a simple example to help. I have included as much around the code that I think may have any effect on the outcome.
Index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.0/dojo/dojo.xd.js" djConfig="isDebug: false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require('dijit.layout.TabContainer');
dojo.require('dijit.layout.ContentPane');
dojo.require("dijit.form.DateTextBox");
</script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dijit/themes/tundra/tundra.css" />
</head>
<body class="tundra">
Works Outside of a Tab: <input class="tundra" id="outsideworking" name="outsideworking" type="text" dojoType="dijit.form.DateTextBox">
<br><br><br>
<div id="tab" dojoType="dijit.layout.TabContainer" style="width:50%;height:200px" >
<div id="tab-working" dojoType="dijit.layout.ContentPane" selected="true" title="Loads on Page Load">
Test working
<input class="tundra" id="working" name="working" type="text" dojoType="dijit.form.DateTextBox">
</div>
<div id="tab-notworking" dojoType="dijit.layout.ContentPane" title="Load On Click" preload="false" parseOnLoad="false" href="loadafter.php">
</div>
<div id="tab-simplenotworking" dojoType="dijit.layout.ContentPane" title="Load On Click with Simple File" preload="false" parseOnLoad="false" href="simple.php">
</div>
</div>
</body>
</html>
loadafter.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.0/dojo/dojo.xd.js" djConfig="isDebug: false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dijit.form.DateTextBox");
</script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dijit/themes/tundra/tundra.css" />
</head>
<body class="tundra">
Outside of a Tab
Not working here:
<input class="tundra" id="notworking" name="notworking" type="text"
dojoType="dijit.form.DateTextBox">
</body>
</html>
simple.php
<input class="tundra" id="simplenotworking" name="simplenotworking" type="text" dojoType="dijit.form.DateTextBox">
Is anyone able to help point me in the right direction?
Thanks
gggggggg
In short, if you have set parseOnLoad as false, you need to parse the html fragment by yourself. And for your tab pages, if you clicked a tab, you may need to parse the tab page manually.
For example:
<div id='a'><input id="simplenotworking" name="simplenotworking" type="text" dojoType="dijit.form.DateTextBox">
</div>
You can use dojo.parser.parse(dojo.byId("a")) to render the widget.
Btw, you do not need to attach tundra class in every places of dijit widgets, it just need to be placed at the body tag,.
Try more sophisticated selector like dojo.query to pinpoint the exact Dom you want.
if you want to select a dijit for the parser you need to do it with dijit
dojo.parser.parse(dijit.byId("a"))
if you use dojo, it will select the dom node.
if you use dijit it will select the widget