Using Output For HTML Elements Outside Canvas
Apr 7, 2009
Before the canvas tag you had to write a script to make a gradient for html element backgrounds. Now you can use canvas and it's as easy as ... well messing with canvas. I have this script. At one point I had the gradient img objects resizing so the gradient would not get skewed. it was simple. just set the height% at the opposite ratio of the canvas width/height. But I went to make some changes and the next thing i knew that no longer worked. I don't remember how I did it!! I'm going to have to start over if I can't figure it out. Here's the script. Canvas only.
I haven't adapted with excanvas for IE yet, but that's coming when I can figure out how I had the thing working right. It's a css issue. I had thought I put the img objects in divs that were sized and positioned and then set the images to width 100% height= 100%*((canvas.width-canvas.height)/canvas.width) So in my example, the canvas was 100 x 30 and the factor is 7 so it would resize the image 700% and the height would grow by the relative amount to the setting I had it. I'll try to figure it out, but there's the script working somewhat. I want to figure out a way to resize the img objects when the user resizes the page, but I want the img to always maintain aspect ratio. [URL]
<script>
/*ORIGINAL SCRIPT FOUND AT [URL]*/
window.onload = function () {
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 100, 50);
g.addColorStop(0, 'rgba(255, 255, 0, 0.5)');
g.addColorStop(0.5, '#0ff');
g.addColorStop(1, '#00f');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
var data = canvas.toDataURL();
document.getElementById('i').src = data;
document.getElementById('EIMG').src = data;
var canvas2 = document.getElementById('c2');
var ctx2 = canvas2.getContext('2d');
var g2 = ctx2.createLinearGradient(0, 0, 100, 50);
g2.addColorStop(0, 'rgba(255, 0, 255, 0.5)');
g2.addColorStop(0.5, '#0ff');
g2.addColorStop(1, '#00f');
ctx2.fillStyle = g2;
ctx2.fillRect(0, 0, 100, 50);
var data2 = canvas2.toDataURL();
document.getElementById('i2').src = data2;
document.getElementById('DIMG').src = data2; .....
View 3 Replies
ADVERTISEMENT
Aug 22, 2010
I'm wondering if there's a jQuery method or plugin which allows me to dump the HTML source of all selected elements, ie. the element(s) referred to by any jQuery object?
As opposed to .html(), which outputs the "innerHTML", I'm looking for something like IE's old "outerHTML" function, which also provided the tag's own code as well as its inner HTML.
For a jQuery object which has captured several elements, I'd like to output *all* the HTML of all those elements at once, in one "dump" as it were. Is that easily doable?
View 2 Replies
View Related
Oct 21, 2009
I'm having a problem with the <CANVAS> element in JavaScript. here's what i'm trying to do: I need 3 different canvas elements for writing a signature to. they must all 3 be visible at the same time
My problem that i'm having is that i can't seem to get the code to work which will write to more than one canvas.
[Code]...
View 2 Replies
View Related
Jan 1, 2011
I have make a javascript program that uses HTML canvas and I can't get it to work in Internet Explorer. I tried using excanvas and jqcanvas but had trouble getting them to work.
View 5 Replies
View Related
Jun 19, 2011
Here's a snippet:
canvases[i] = document.createElement('canvas');
canvases[i].style.width = '3px';
canvases[i].style.height = '100%';
canvases[i].getContext("2D");
canvases[i].fillRect(1,0,1,table_height);
I'm trying to dynamically create a canvas element. Later in the script it gets attached to the DOM, and this works fine if the last two lines are missing. I end up with a canvas element that is 3px wide and 100% of the containing div tall. However, the last two lines make it crash, with the error report 'canvases[i].fillRect is not a function'.
If I change the last two lines to:
var drawing = canvases[i].getContext("2D");
drawing.fillRect(1,0,1,table_height);
It says 'drawing is null'. Something seems to be going wrong with the getContext bit, because setting the height and width work fine. It behaves the same if I append the canvas element to the DOM before trying to do the drawing as well. This is in FF4.0.1 with a xhtml1-strict.dtd doctype and valid html.
View 7 Replies
View Related
May 18, 2010
My application is based on client-server architecture. It is a E-Learning Application. I am using ruby on rails server, javascript,canvas,SVG element. I have an idea of an interface to allow the teacher to build any type of animation for students using Cake javascript API. I wanted to save the animation build using the canvas element on the rails server either in database or as a file. Later I have to use that animation to be played to students. Any way to do it on any language except proprietary languages like flash but from that language communication can be done with rails server.
View 1 Replies
View Related
Jul 12, 2011
I want to delete some lines on the canvas that i have created in HTML5 (with the <canvas> tag). I know one solution and that is using clearRect() (give this function the HEIGHT and WIDTH of the canvas and you clears the whole canvas.).But i don't want to clear the whole canvas, i only want to delete a few lines made by the function lineTo().
View 1 Replies
View Related
Mar 16, 2009
I have a menu in which is applied typeface script. Typeface 0.11 version doesn't support hover on links. There is an experimental version but doesn't work very well for me, so i tried to implement hover by myself.
Problem is: hover works pretty well changing canvas context property fillColor and then calling fill(), but the stroke on hovered voice remains on another color. Difficult to explain, so i put some test code online: TEST CODE As you can see, passing with mouse on the menu voices triggers the hover and the element change, but remains bordered in red.
[Code]...
View 5 Replies
View Related
Mar 19, 2009
I was not sure where to put this - the CGI or Javascript file. Anyhow, I have a CGI counter that I pulled off the net, which I like a lot. The counter works perfectly.
I am using Javascript to include the output (i.e. the counter) in my HTML file for now. Again, I have accomplished this too. However, I want to be able to apply css style to this particular output - nothing fancy, just a border and background and change the font and spacing. However, I am unsure how to accomplish this with the way I have it coded. You can visit the site at paradigmforward.com/alpine/index.html - the counter is at the VERY bottom.
[Code]...
I am sure this is easy, but cannot figure it out. I would like to keep it within the footer div.
View 2 Replies
View Related
Jan 25, 2010
How to make it works if #register_user is added by function Register() ?
$("#register_user").focus(function() {
$(this).attr("value","");
});
Whole script:
[Code]....
View 1 Replies
View Related
Jan 27, 2011
I am calling 2 scripts, that are variations of the same script, and am getting unwanted duplicate output into the other div (place-holder) on an html page. I thought it was a scope issue, but that doesn't seem to make sense. The page is: [URL]
features.js
$(document).ready(function() {
$.get('xml/features.xml', function(f) {
$('#y-place-holder').empty();
$('#y-place-holder').append('<dl class="feature" />');
$('feature', f).each(function() {
var $feature = $(this);
var fimageurl = $feature.attr('imageurl');
var fseries = $feature.attr("series");
var ftitle = $feature.attr("title");
var fdates1 = $feature.find('dates1').text();
var fdescription = $feature.find('description').text();
var ffeature = '';
ffeature = '<dd>'; .....
View 2 Replies
View Related
Jun 11, 2009
I an wanting to make a form where all of the text fields will be output in html table format to a new webpage. For example, Name, Age, Location, etc. When the user clicks submit I want to write a new html file based on the user's name (for exmaple chris.html). This seems like it would be fairly easy to do. Can anyone give me example coding to get me started?
View 2 Replies
View Related
Mar 27, 2009
I am a newbie to Javascript and JSP. I wish to create a jsp file to read the inputs from an html (registration form called member.html), check validity of inputs using javascript and finally generate an ouput as an html file displaying the user inputs. Following is the code for the member.html file
<HTML>
<TITLE>New member application form</TITLE>
<script language="JavaScript" src="javaScript.js" type="text/javascript"></script>
<!--<HEAD><H2><P align = "center">Welcome...</P></H2>-->
<H2><P align = "center"> Member Registration Form </p></H2>
</HEAD>
<HR>
<BODY> .....
The error I experience is that nothing happens when I click submit button. I have installed Tomcat 6.0 and do not seem to have issues with that.
View 3 Replies
View Related
Jun 3, 2010
I have HTML tags stored in XML. I want to be able to use these HTML elements with Javascript, just as you can with elements in document.body. How can it be done? (And don't try and tell me I should use server-side because I have written it all for Javascript and the project is nearly complete minus this and there are practical reasons for not doing this server-side. After all, anything is possible with Javascript!)
Let me explain:
- I have HTML templates such as this [URL]
- I want javascript to populate these templates then add them to my page
- The only way I know javascript can get this kind of data is by parsing XML
- I want to parse the XML then be able to use the HTML elements just like those in document.body
- As far as I'm aware, XML is the only good way of storing data for javascript. I don't want to store it in javascript variables (too much multiline data with " and '). Nor do I want to build it using document.createElement("div")... etc
As someone not yet with any experience in computer science etc, please ignore my poor terminology! However, I'm not a beginner when it comes to javascript.
Here's the script concerned but I doubt it'll help you understand my problem: [URL]
View 6 Replies
View Related
Apr 22, 2006
I have been trying to do the following. Using JS I want to create an
input element (text box) and attach a event listener. I have done in
in two different ways. The first is using xml elements directly (as in
e4x) and the second using the dom method createElement (which is much
clunkier to write). I'd prefer the former. I've included a stripped
down example below.
It appears that when creating an input element using the line:
var inputBox = <input type="text" size="30" />
that it does not have the same properties as when it is created with:
var inputBox2 = document.createElement("input");
because when an event listener is attached using addEventListener, an
error is generated on the first, but not the second.
My thoughts on this are either
1. The namespace for the input element is not correct and whether input
can have a listener attached. However, my guess is that it would not
show up in the first div box. Code:
View 4 Replies
View Related
Sep 2, 2010
check the following piece of code:
<html>
<head>
</head>
[code]....
I am trying to get <p id="p2">Test1</p> above <p id="p1">Test2</p> using javaScript only.
View 4 Replies
View Related
Jan 17, 2006
Here's my situation:
1. I have a web browser component that does not support Javascript
(well it does, but we've disabled it)
2. I have to display some HTML in it, where the user has a link titled
"Hide|Show Options" that can hide/show a particular section of the
HTML.
I have not found a way to achieve it without using Javascript or any
other scripting language.
Is it possible to do this using pure plain HTML?
View 3 Replies
View Related
Oct 5, 2006
Is there a possibility to find out the coordinates, relative to the whole
screen, or at least relative to the browsewindow, where an element ( e.g. link or
picture ) begins or ends?
View 2 Replies
View Related
Nov 9, 2006
I'm looking for an alternate way to document.all to list all HTML-elements on a webpage.
I'm trying to get all IDs on a page that starts with specific letters,
ie: <div class='classname' id='MEIT_Start'.....
I wan't to build an array of items starting with 'MEIT_'
I have tried to use getElementByID but no succes...
View 2 Replies
View Related
May 11, 2010
This may be a repeat post, but I can't seem to find the answer in these forums. Here is the question: I have a div with id "someDiv". I am obtaining an HTML string via XHR and intend to insert it in the DIV. I use .html(theHtmlString) and it renders just fine. But the newly inserted elements are not in the DOM - either by name or id. How do I register them in jQuery?
View 2 Replies
View Related
Feb 4, 2005
I got this javascript widget finished the other day. It's called BoxOver and allows floating captions over HTML elements, similar to overlib but uses less CPU and is much smaller (<10kb).
Would be super keen to hear any comments/criticisms on it. Also if anyone has any ideas for changes that would be cool too....
View 19 Replies
View Related
Jan 27, 2011
I have a HTML document with form. The form has several radio buttons. I want different elements of HTML (including <input> elements) to appear when each radio button is selected. Also, it is intended to show only those elements for a specific radio button. For example, if i select RB1, it shows me element div 1 and hides all others. If i select RB2, it hides element div 1 and shows element div 2, et cetera. So far it works fine with .style.visibility = 'hidden' and 'block'. Now, here comes the problem - each element appears below the previous element, they appear as they are in the HTML, no matter if i show the previous one. It looks pretty bad, because element positions are jumping as i select different radio buttons. How do i keep them in the same level, at the same position?
View 3 Replies
View Related
Apr 10, 2009
The following is a JS ticker.It works well, but I can't figure out why the text in italic tags is being printed with the tags, instead of becoming italicized.example is here:
[URL]
Code:
<div>
<span id="tick"><a href="#"> </a></span><span id="cursor"><img src="http://www.sposa.com/images/feedicon.gif" border="0" alt="_" height="10" width="8" /></span>
<script language="javascript">
[code]....
View 2 Replies
View Related
Dec 27, 2010
I am writing a javascript method to add/remove HTML elements using Javascript.
I use cloneNode to clone the element.
Following is the code
Code:
<HTML>
<HEAD>
<TITLE>Dynamically add Textbox, Radio, Button in html Form using JavaScript</TITLE>
<SCRIPT language="javascript">
[Code].....
View 4 Replies
View Related
Sep 30, 2011
I've gone back and forth on the best way to store data in HTML elements which is used to support JavaScript. For instance, I might have a bunch of rows each associated with a SQL ID, and upon clicking the delete element, want to grab the id, and send it to the server. I've successfully used the following three solutions, but would like to standardize on just the best.
Option 1 is technically valid, but seems excessive. Option 2 will work fine, but is considered by some as bad practice. Option 3 requires the extra step of splitting the ID from some identifier string, and care not to have the same record twice on the page.
HTML Code:
View 10 Replies
View Related
Dec 15, 2009
I've lately stepped up a little problem with one of my personal projects that i am working. I'm writing an aspx webpage, which includes web user controls inside it.
The webuser controls are within a web form (id=form1 runat=server) which resides in the
main.aspx page.
1. First of all, is there a way to find a SPECIFIC control inside the webuser control (ascx)
using Javascript in the main.aspx?
2. If not (which i think it is), which is the best way to do it? The snippet i tried was this:
[Code]...
View 2 Replies
View Related