Basic ReactJS application [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I decided to write a simple page using ReactJS, but I'm new to it. The code snippet below doesn't work for an unknown reason (at least for me). What's wrong wrong here?
<!DOCTYPE html>
<html>
<head>
<script src="bower_components/react/react.min.js"></script>
<script src="bower_components/react/react-dom.min.js"></script>
<script src=bower_components/babel/browser.min.js"></script>
</head>
<body>
<div id="my-div"></div>
<script type="text/babel">
var Message = React.createClass({
render:function(){
return <h1>Hello, world!</h1>
}
});
ReactDOM.render(<Message/>, document.getElementById('my-div'));
</script>
</body>
</html>

The only thing that I can imagine is wrong with this code - is wrong path to scripts. Check console for problems with such problem.
Try to use maybe a CDN react instead of these from bower and tell what result is. Also, if you don't want to try CDN maybe try to add "/" before bower_components, that is
../bower_components/react
/bower_components/react
(wild guess)
Dom
React

I am very sorry for posting a silly question. I made no mistakes in my code except for one.
src=bower_components/babel/browser.min.js"
I missed a quote symbol. It should be:
src="bower_components/babel/browser.min.js"
Anyways, thank you for your attempts to help me.

Related

Javascript a.hover doesn't work [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I took this css theme which is working with javascript and i have a problem with the a.hover (not working):
http://cssdeck.com/labs/zg4cr9hu
This is the first time i use javascript and i think that the problem comes from the jquery.min.js file i took from the library...
In the <head> i wrote in the html page :
<script src="script_intro.js" type="text/javascript"> </script>
<script src="jquery.min.js" type="text/javascript"> </script>
Is this where the error comes from ? Or should i put something in the js file that i didn't touch (seems good without errors)...
Thanks in advance for answers :)
If you are using jQuery in your first script you have to invert the lines, jQuery first and after the scripts that make use of jQuery.
<script src="jquery.min.js" type="text/javascript"> </script>
<script src="script_intro.js" type="text/javascript"> </script>

Load page then execute javascript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need a way to automate on startup opening a URL then once the url has loaded call an on page function
And i have no idea how to approach this, I cant think of a way to do it via powershell and I dont know any other language very well any help would be appreciated even more so if it was written for a 5 year old.
Im not sure if im understanding correctly... but maybe you are looking something like this:
<html>
<head>
</head>
<body>
<!-- Put your html here -->
....
....
....
<!-- Scripts the bottom of the page -->
<script>
startup_function();
function startup_function(){
alert('Hello');
}
</script>
</body>
</html>
PLease keep your javasript file inside body after html . and use
window.load();

Why would JavaScript work correctly in HTML body but not as a JavaScript file in the HTML header [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
This doesn't work (placed inside the HTML header tag):
<script src="files/js/animater/index.js" charset="utf-8"></script>
But this works fine (placed inside the HTML body tag):
<script>
$(function() {
$(".active").animate({height: "10%"}, 5000);
});
</script>
Why does the last one work correctly and the first one doesn't?
Take out the script tags in the .js file.
In index.js file write this way,
(function() {
$(".active").animate({height: "10%"}, 5000);
}());
I hope you'll enjoy :)
You need to run your function some how. Like
<body onload="animate()">.
Otherwise you will need some on document load script in your jquery file. More Info
You may need an opening slash in your source path: src="/files/js/animater/index.js" and you shouldn't need the character set attribute. You may also need to add type="text/javascript" as an attribute.

Request Assistance on HTML5 Banner [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Salutations! fellow developers, I am kind of stuck in a pickle here. I managed to create a HTML5 animated banner for my blog. After the exported content I received these two files:
i) banner.html --> I can change the name of this to whatever I want and functions perfectly.
ii) sprite.js --> When I change the files name, location and content. The "banner.html" automatically stops to functioning/working.
Is there a possible way that I can just have the "banner.html" file to function properly with my content without the "sprite.js".
-If yes, please share your solution.
-If no, please explain alternative working solution that you deem necessary.
Thanks to anyone who had answered.
-LEO
You can include scripts directly into HTML documents with the SCRIPT tag:
Substitute
<script src="sprite.js"></script>
(which has to be somewhere inside the HEAD tag of your document) with
<script>
<!--
//contents of sprite.js go here
//-->
</script>
Open your banner.html in a text editor.
There should be a line line
<script src="sprite.js"></script>
Replace it with
<script>SOURCE_OF_SPRITE.JS</script>
Of course "SOURCE_OF_SPRITE.JS" should be the actual source.

JavaScript script reloader [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Im a little new to HTML programming so I wasn't sure what to do. Im trying to make this script that I have written reload constantly (every second) without refreshing the page. I know that it is supposed to be using the tag but Im not sure what to put after. Thank you for reading, hopefully someone will help.
I think you mean reload without user interaction. You don't need javascript. Place this in <head>
<meta http-equiv="refresh" content="1" />
or if you really want to use JS, place this before </body> (or before <head/> if you're old school).
<script>
window.onload=function(){
setTimeout(function(){location.reload(false)}, 1000);
}
</script>

Categories

Resources