I have another interesting mystery for you to solve.
Situation
I basicly use a PowerShell script to generate HTML pages. A meanigful example for this Powershell script would be as following: (Please note this is not the real complete code, but to understand the problem it should be enough)
function New-HTMLPage {
$htmlexport = #"
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Test</title>
</head>
<body>
...further HTML code blabla
"#
return $htmlexport
}
$htmlexport = New-HTMLPage
$htmlexport | Out-File -FilePath "C:\Test.html"
Today i tried to implement a Side Navigationbar into my HTML Code. For this Navigation i used JavaScript in my HTML which i imported like so within the body tag:
<script src="assets/js/sidebar.js"></script>
This is how the Sidebar looks like without powershell:
But when i generate this HTML Page with my Powershell Script (like the example above) it looks completly shredded.
=> Now the interesting part is, that when i copy the generated Powershell HTML Output and paste it into a clean HTML file it looks perfectly fine (like the first picture). Nothing shredded ?!
So my conclusion is, that it is wether a general HTML syntax problem nor a issue in powershell.
Does anyone have an idea what i am missing out or maybe what i can try to solve the issue ?
P.S: If you require any further information please do not hesitate to ask. I have deliberately not included every detail here so there are not too much information.
Thank you very much for your help!
Thank you very much to #mkelement,#jdweng,#Theo for providing this answer.
Finally the paramter -Encoding from the Out-File helped to sove the problem.
To find out the right encoding it followed the instructions from #Theo's comment.
Finally the correct CMDLet was:
Out-File -Encoding utf8 -FilePath "$Filepath"
Related
the task is quite simple, I guess. I would like to produce screenshots (png - files) from local html files.
My 'proof of concept' looks like this...
The files are located on a windows 10 machine in a local folder: c:\temp\
This would be a very basic html file - just to make sure that no sophisticated stuff is disturbing (file called: a.html):
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- otherwise format might be broken when opening from local source -->
<title>Savills Charts</title>
</head>
<body>
<h1>HalloBallo</h1>
<p>My baby baby, Balla Balla!</p>
</body>
</html>
The script which calls phantomjs was taken from here: http://www.cameronjtinker.com/post/2011/09/26/Take-Screenshot-of-all-HTML-documents-in-a-folder-using-PhantomJS.aspx
During my work I thought my own script was the problem but it doesn't look like it is.
var page = require('webpage').create();
page.open("file:///c:/temp/a.html", function() {
page.render('C:/temp/screenshot.png');
phantom.exit();
});
phantomjs is producing only black .png files.
If I switch the source from something local to something on the web
page.open("file:///c:/temp/a.html"
to
page.open("http://spon.de"
then everything works fine....
I'm lost...
What can I do?
KR,
Martin
Maybe someday someone stumbles as I did.
Therefore I want to clearify. The problem was, that (in contrast to a web browser) phantomjs does not set any colors by default. So in the website given (see example code) phantomjs simply renders black writing on black background.
If you give the body a backgroundcolor then you will see the black font.
So - it's solved.
Martin
I just started learning javascript about 30 minutes ago. I'm doing an online course and they gave me this code as an example. The person in the video did the exact same thing, but it only works for me when I do inline not external. My .js name is right and they're in the same folder.
The html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Basics</title>
<script src=“cripts.js”></script>
</head>
<body>
<div class="container">
<h1>Where to place your JavaScript code.</h1>
</div>
</body>
</html>
and the js:
alert("YOU");
Nothing appears for me. I've tried everything to make it work, including different browsers. Could it be my computer or did I make a simple mistake?
It looks like your quotes are invalid :') Good beginner move! But it will be a simple fix. Note the “ should be ", this usually happens when copying and pasting code!
<script src="cripts.js"></script>
Also make sure your path and file name is correct?! cripts.js sounds like it is suppose to be scripts.js
A beginner mistake I made was to use <script>...</script> tags in the external javascript file. From HTML if you use:
<script type="text/javascript" src="../myApp/myFile.js"></script>
Then the external js file should just contain just the code such as:
function myFunction {}
with no script tags. This is unlike linking to external css files which include the <style>...</style> tags.
I am trying to display some Hindi words using JQuery because these are the common content which should be display on each page of the web site.
Note - This is a static website only. Using HTML and JQuery/javascript.
My JS file is below -
include.js
$(document).ready(function(){
var text="<div class='header-main'>मुख्य पृष्ठ कुछ हिंदी के शब्द </div>";
$(".header__fixed").html(text);
});
my html file is -
index.html
<body>
<header class="header header__fixed">
</header>
</body>
But it is displaying something like -
????????? in the header div.
Please help me to solve this problem.
Here is the screen shot of the error when i am saving the .js file.
Please help me to get out this problem.
I already included the in my html file.
Add <meta charset="utf-8"> to the <head> of your HTML.
hi first off all you need to add this two things in to html tag encoding="UTF-8" charset="UTF-8" like..
<html encoding="UTF-8" charset="UTF-8">
and yes the second is the main thing that you need to save this html with Encoding in UTF-8 option this will make hindi characters available try this by creating example locally this will run
I got the answer of my problem... It is so simple.. Just save the file with Unicode character set. I am using dreamweaver and have changes the character type by saving as file.
<html encoding="UTF-8" charset="UTF-8">
my JS-File is UTF-8 encoded, my html document also.
I also have this in the head part of the HTML:
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8" />
Every umlaut that I typed in the HTML is displayed properly.
But if I try to set a new value with $('#test').text('Test öäü') I get Test öäü.
How is this possible? Even console.debug/log and alert() display the same.
I also tried to set the charset attribute on my script-tag, but nothing worked.
Can anybody help me with this issue?
I found the issue. I use minify to combine my css/js and minify had $min_serveOptions['contentTypeCharset'] set to iso-8859-1.
I'm trying to print some Japanese to a page dynamically using jQuery, and it display nothing recognizable. I don't know what went wrong, I reduced the code to the most straight-forward, and it doesn't fix it. Or maybe it's just me being thick.
I use:
$('body').append('<p>日本語</p>');
Which should work, right?
And I get:
日本語
Huh?
Have you made sure that your page is set to use the Japanese character set? If not, make sure that your charset is defined in your <head></head> node :
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
In some cases Utf-8 character set would be helpful. Add this in your Head node as below.
<head>
<meta charset="utf-8" />
</head>