Convert HTML string to HTML file with adding Tabs? - javascript

I have a string that is HTML codes, but they are all in one row, I want to create an HTML file, with this string and organize the code by adding \t, correctly according to the HTML syntax..
From:
<!DOCTYPE htmL>
<html>
<head>
<meta charset="UTF-8">
<title>Title goes here</title>
</head>
<body>
</body>
</html>
To:
<!DOCTYPE htmL>
<html>
\t<head>
\t\t<meta charset="UTF-8">
\t\t<title>Title goes here</title>
\t</head>
\t<body>
\t</body>
</html>
I want it to be added inside the string, so that I can then create an HTML file, correctly and orderly..
I tried many ways, but I didn't find the right solution for that

Related

How to create a to do list with only javascript?

How can I create a to do list with just javascript? I have a html file with only 1 div and have to do this with just javascript?
example
This is my html file...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>To do App</title>
</head>
<body>
<div id="app">
</div>
</body>
</html>
The rule is that I can't add more html tags
Please help!!!
Well, you have to add more tags.
You don't have to write those tags into your HTML file, you can create elements using JS.
Components that you can create in JS
Search Bar
Todo Item
Button
After writing these components you can plug and play your logic.

How to remove style html entity

How to style html entity using css and jquery. (ŵ) is showing bold more than other letter.
<!doctype html>
<html>
<head>
<title> My First Webpage</title>
<meta charset="utf-8" />
</head>
<body>
<div>
Glyndŵr's Way
</div>
</body>
The first step is to add your text into the div and adding a stylesheet for this div
div{
color:red;
}
<!doctype html>
<html>
<head>
<title> My First Webpage</title>
<meta charset="utf-8" />
</head>
<body>
<div>
my text
</div>
</body>
I use Atom. What I do is create a separate file for css only saving it as (whatever you want to save it as .css) ON THE SAME FOLDER and link it to my html document using the at the beginning of the html document.

How to append a whole html file with jquery

I got a html file like this,
<!DOCTYPE html>
<html lang="en">
<head>
//some content
</head>
<body>
//some content
</body>
</html>
My question is how to load this file as a whole with jquery. I tried it with
append function, but it didn't work.. I searched for the solution for quite a while, but just found a lot of methods to append some parts of html file, like meta, link, not a whole file.
Can I do it with jquery?
index.html or whatever
<iframe src="filename.html"></iframe>
filename.html
<!DOCTYPE html>
<html lang="en">
<head>
//some content
</head>
<body>
//some content
</body>
</html>
You can use <link> element with rel attribute set to import, href set to path to file, type set to "text/html". Use XMLSerializer() instance .serializeToString() with replacement document .doctype property as parameter to get <!DOCTYPE> declaration from imported document; document.write() with .import.documentElement.outerHTML property of link element as parameter to replace existing .doctype and <html> node with .doctype and <html> of imported document.
<!DOCTYPE html>
<html lang="en">
<head>
<link id="doc" rel="import" href="https://gist.githubusercontent.com/guest271314/9921cb52b143437b23f23fa32284ca35/raw/86532c043b666bce15b33c91dc29e98615dd4e25/replacementDocument.html" type="text/html" />
</head>
<body>
//original content
<button>load html document</button>
<script>
var link = document.getElementById("doc");
document.querySelector("button")
.onclick = function() {
// http://stackoverflow.com/a/30565562/
var dt = new XMLSerializer().serializeToString(link.import.doctype);
document.write(dt, link.import.documentElement.outerHTML);
document.close();
}
</script>
</body>
</html>

HTML not supporting arabic language

I am working on a project which i need to convert it in Arabic. i am using codeigniter. when I write the Arabic in html it show me that (?????) for Arabic.
This is my HTML code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title></title>
<meta name="" content="">
</head>
<body>
<h1 dir='rtl'
lang='ar'>checking</h1>
<p dir="rtl" lang="ar" style="color:#e0e0e0;font-size:20px;">رَبٍّ زِدْنٍي عِلمًا</p>
</body>
</html>
it shows me text like that:
As i can see you are using some html5 based attributes like dir so you need to convert the html4 document to html5 doctype and use lang attribute on html tag and meta tag:
<!DOCTYPE HTML>
<html lang="ar">
<head>
<meta charset="utf-8">
A sample demo is below:
<h1 dir='rtl' lang='ar'>checking</h1>
<p dir="rtl" lang="ar" style="color:#e0e0e0;font-size:20px;">رَبٍّ زِدْنٍي عِلمًا</p>
the view source of this snippet looks something like this:
Try with adding meta charset for arabic at the begning
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-6">
or
Displaying Arabic text using PHP
Don't use the short tags . Use the full tags
Remove the quotes and semicolon from the first line and others that are outside the php tags
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">";
Close the span tag <span lang='ar-kw'
Make sure save the file with utf-8 encoding. You might be saving it with another coding.
Use the below as your startup file, it is HTML5, also with this <html lang="ar" dir="rtl"> you won't need to repeat it in every single element. use this and you're fine.
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
</head>
<body>
<!-- your HTML structure -->
</body>
</html>
Concerning your issue: JS Fiddle 1 and JS Fiddle 2 -no need for lang attribute
In charset value, instead of using utf-8, use windows-1256
Add in you php connection code just:
$conn = new mysqli($host,$db_user,$db_password,$db_name);
$conn->set_charset("utf8");
And in you dislay php data code:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
be sure if your file encoding is utf-8 to make this open your file in notebad then save as then you can see this below to select utf-8:
if you use eclipse you can update the files default encoding through windows-> preferences then from left side you can expand general and select content types, and by selecting the file type you can assign its default encoding then click update like the image below, also you can find the way for each editor to update default encoding:

JavaScript won't work if placed inside the body of a web page?

I'm new to JavaScript and I've learned that JavaScript can be place between the <head></head> or <body></body> sections, I have been working in a project and it works fine inside the head but not the body section of the page.
examples:
working fine like this:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example Page</title>
<script>
function yetAnotherAlert(textToAlert) {
alert(textToAlert);
}
yetAnotherAlert("Hello World");
And is not working this way:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example Page</title>
</head>
<body>
<script>
function yetAnotherAlert(textToAlert) {
alert(textToAlert);
}
yetAnotherAlert("Hello World");
</script>
</body>
</html>
Your code snippet didn't show you closing the tag. Double check if you close your script block correctly.
It's also better to specify the type of scripting language too.
<script language='javascript'>
....
</script>

Categories

Resources