Tag: html5

How to define a variable in JavaScript with PHP echo function?

How do I define a variable in javascript with echo function, from the external php file? We have theconfigfile.php, thejsfile.js and thephpfile.php. In theconfigfile.php we have: <?php $path = ‘http://example.com/home.php’; // Set your path ?> In thejsfile.js we have: … if (confirm(“Are you sure you want to delete”)) { $.ajax({ type: “POST”, url: “http://example.com/home.php”, data: […]

How to tell if an element is a child of another element in JavaScript (no jQuery)?

If I have 2 HTML elements, how can I easily tell if 1 is a child of the other? var parent = document.getElementById(‘shapes’); var child = document.getElementById(‘star’); Is there any kind of function on an element like child.getParentElement() that I could compare with like child.getParentElement() == parent? I understand parent.children gives me back an array […]

Draw text along the bezier curve in paper.js

Is it possible to easily draw text along the bezier curve using paper.js? I know it is possible to attach text to a line path and then rotate it, but I am interested specifically in drawing text along the curve. Something like http://www.w3.org/TR/SVG11/images/text/toap02.svg I understand this may be achieved by printing text a letter by […]

Bootstrap Sidebar menu and Sidebar navigation

I’m using bootstrap and it just happen that I wanted to create a responsive website that’s why push me through to use bootstrap. What I want to do is something like on the photo. (NOTE: not the entire page but only the sidebar with the icons.) That’s exactly what I want on my sidebar. I’d […]

making a tag target of event, not img

This is probably javascript 101 but I can’t figure out a solution to this. Consider the following fiddle My js sets the click event on the a tag using the class .show-modal and yet my console log shows that the event target was actually the img tag. I need the event target to be the […]

Jquery function doesn't work after Ajax call

I’ve got this function: $(document).ready(function() { $(‘.post_button, .btn_favorite’).click(function() { //Fade in the Popup $(‘.login_modal_message’).fadeIn(500); // Add the mask to body $(‘body’).append(‘<div class=”overlay”></div>’); $(‘.overlay’).fadeIn(300); return false; }); My page loads content with favourite buttons, but after Ajax call and generated additional new content the function doesn’t work when you click new content’s buttons. What could be […]

How to get the value of data attribute using jquery

I am working on a node.js application which generates a html page. This html page displays a list of associates built according to the data passed onto this page. A list is built something like as follows: <ul class=”notification-body” style=””> //loop for all assocaite id’s passed to this page <li class=”testClass” data-associateid=”<%= assocID %>”> <span> […]

HTML5 Web Storage vs Cookies

I want to display a message to first time visitors of a specific page on my site. The message will only need to appear once. This would be pretty simple to do using cookies but is there more benefit to using HTML5 localStorage? If so how would it be implemented?

Canvas FPS artificially limited to 100fps?

In this page that counts the number of frames rendered and prints the FPS onto the canvas, we can see that it tops out at 100fps, which seems suspicious at the least. Why is this? <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”utf-8″> <title>Canvas FPS artificial limiting</title> </head> <body> <canvas id=”c” width=”320″ height=”240″></canvas> <script> var c […]

Is there any way to prevent people from making my web game available offline?

It’s not the type of game that really need a server to operate. I’m using javascript and html5 right now, and I cant think of a way to prevent the game from being rip off. Using obsfucator is useless, the game would still work offline. Implementing a validation scheme is not invincible either. Someone smart […]