Use Of Speech Marks When Writing Function To HTML

Jan 13, 2009

I've been using the document.write function to loop through some xml and print the data within a HTMl table. I thought it would be useful to add a hyperlink to the table row, so I thought the best way to do this would to create a function (called popup), which takes an id as a parameter.

The problem with this, is that when writeing using the onClick, the speech marks seem to all get messed up.

Code:

onclick='popup('"+mailID+"')'

I'm 99% sure it's just the speech marks, i'm just not sure of the right combination, and it's doing my head in

If someone could even point me in the right direction, even the proper name as to what this is called would be great, as googleing it is proving to be a nightmare!

Here's the whole section of code if it's more useful:

Code:

var mailID = x[i].getElementsByTagName("mailid")[0].childNodes[0].nodeValue;
if (r == "unread") { //email is unread
document.write("<tr onclick='popup('"+mailID+"')' title='test'>"); } else { //else is read, so add colour

[Code]....

View 4 Replies


ADVERTISEMENT

Dynamically Writing Html/javascript From A Javascript Function

Jul 23, 2005

I'm working on some code and am running into brick walls. I'm trying
to write out Javascript with Javascript and I've read the clj Meta FAQ
and didn't see the answer, read many similar posts (with no luck
though), and searched through the IRT.ORG Faqs
(www.irt.org/script/script.htm).

The Javascript is designed to open an popup window and then inside that
window call another script which will resize that window. There may be
another way around this but the reason I tried this approach initially
was that I wanted to call the onload handler in the popup window to
resize the image only after the image had completely loaded. I've had
some code in the primary Javascript file (showimage.js) before that
works if the image has been cached but on the first load, it doesn't
resize properly which tells me it is probably because it is trying to
resize the window based on the image size but it isn't completely known
at that point. So I removed that code and tried placing the resizing
code in the second Javascript file (resizewindow.js). BTW I've tried
other code to open a popup image and automatically size it ie Q1443 at
irt.org but that doesn't do exactly what we need.

Even if there is another way to do this with one file, I still want to
figure out why this isn't working in case I run into it in the future.

I thought what I would need to do to use document.writeln to write
Javascript would be to escape any special characters and to break
apart the script tag ie

document.writeln('</SCRIPT>');

would become

document.writeln('</SCR' + 'IPT>');

I have a HTML page and 2 Javascript files. All files are in the same
directory and have permissions set correctly.

Here are the 3 files (keep in mind wordwrap has jacked up the
formatting):

index.html
----------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1"
SRC="showimage.js">
</SCRIPT>
</head>

<body>
Click the house<BR>
<A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG
SRC="house1thumb.jpg"></A>
</body>
</html>


showimage.js
------------
function newWindow1(pic,sitename)
{

picWindow=window.open('','','width=25,height=25,sc rollbars=1,resizable=1');
picWindow.document.writeln('<html> <head>');
picWindow.document.writeln('<SCR' + 'IPT type="text/javascript"
LANGUAGE="JavaScript1.1" SRC="resizewindow.js"></SCR' + 'IPT>');
picWindow.document.writeln('</head>');
picWindow.document.writeln('<body onload="resizewindow();">');
picWindow.document.writeln('<img src=' + pic + '>');
picWindow.document.writeln('</body> </html>');
picWindow.document.close();
}

resizewindow.js
---------------
function resizewindow()
{
// Do resizing here.
// Right now this isn't being executed
alert("resizing window");
}


Can anyone provide some pointers as to why this javascript is failing?
I'm using IE6 on Win2k and when I click on the image to open the popup
window, it does open the window but it is white with no content and the
system immediately goes from about 4% CPU usage to 100% and
consistently stays there until I kill that window with the task
manager.

View 9 Replies View Related

Text To Speech On Windows XP

Mar 18, 2006

I have installed WINDOWS Xp on my machine. SAPI (Microsoft Speech API) is in built in WINDOWS Xp. I am trying to implement Text - To - Speech using a java script. But i couldnt succeed.

Following is the code snippet i am running.

Above script is failing at the following line :

Error Says : Automation server cannot create object.

What is wrong with the above script. Do i need to install any other software on WINDOWS Xp to make Text - to - Speech work ?

Step by step procedure to implement Text - To - Speech on Windows XP machine using Java Script. And what are the prerequisites for Text to Speech on Windows XP machine?

My basic requirement is my web page should talk.So please let me know what are the other possible ways Text to Speech using java script (except <bgsound>). Because i want male,female,child etc voices.

View 5 Replies View Related

Writing Event Handler In HTML Tag Vs. Via Scripting

Dec 5, 2005

<td onMouseOver="foo(event,this,'string');">something</td>

It works fine i.e. the event handler function foo is fired with the
event parameter containing the event. I do the cross-browser thing to
handle the event parameter
var evt = (evt) ? evt : ((window.event) ? event : null);
and I am all set

But when I try to do the same thing by scripting i.e. get the TD node
via the DOM and add in the event handler like so
var td=document.getElementById('tdid')
td.onmouseover=function() {
foo(event,this,"string");
|

It works in IE, but in Firefox (1.x), I get an error in the JS console
"event is not defined".

Why is this? Any way to get consistent, cross-browser behaviour?

View 3 Replies View Related

Have Quotation Marks In Confirm

Oct 31, 2006

Is it possible to have a javascript confirm show quotation marks in the alert?

View 2 Replies View Related

Writing Function With Php?

May 31, 2009

I am "writing" a javascript function to my page with php:

<html>
<head>
<title>Just about everything</title>

[code]....

View 4 Replies View Related

Error While Writing Scirpt Code In Action Attirbute Of Form Tag In Html

Jun 9, 2010

In the below code i tried to write java scirpt in action attribute of form tag in html . Why i wrote that was i want to get the scirpt variable as a part of the url of the target page. I also tried using the location.href="targetpage?value="+value . But It is not redirecting to targetpage because of the action attribute in the form tag. And if we use location.href without action attribute only that script variable was posted and all other remaining textboxes and other form items are being not posted .. Thats why I wrote the scirpt in action attribute. I want the action attribute to work and also the java script variable to be posted .so i wrote the script tag in action attribute of form tag .

[Code]...

View 2 Replies View Related

Writing A ToFixed Function

Jul 20, 2007

I'm not that familiar with javascript, and I am trying to write a
toFixed function.

The function takes two arguments, the number and the number of decimal
places we're interested in.

If the number of decimal places is negative, it's interpreted as the
number of significant digits.

Thus:

toFix(12345.6789,2) -12345.67
toFix(12345.6789,0) -12345
toFix(12345.6789,-2) -12000

I've hacked up a solution that so far works on all tested browsers for
the first 2 cases.

It's the last one I'm having trouble with... How do I get only the
significant digits?

It has to work for all of the following cases:
toFix(12345.6789,-2) -12000
toFix(12345.6789,-5) -12345
toFix(12345.6789,-7) -12345.67

View 2 Replies View Related

JQuery :: Writing A Chain Function?

Jun 12, 2011

I'm sure a Google search could answer this, but I don't know what it's called, haha. Dot sytax maybe?chain methodsHow do I write a function that can be called like this:

$('p').myFunction().val('the new value');

I played around, tried this:

function myFunction() {
$(this).css({'color': 'red'});
}

[code]....

View 4 Replies View Related

Writing Function Output Values?

Jan 20, 2009

I've got a glitch somewhere and it's not obvious to me. Maybe someone can spot it.My problem is that the functions seem to return values but don't display them like they should. I'm testing returned values with a function called sayvalue(item). But when I test "DelTimeCode" the function returns "[Object]". I don't understand. I get returned values from DelTime and DelTitle.My approach is to select a radio button option, return a delivery title and a delivery price from the appropriate functions then write the information. I think I'm close. Any suggestions or observations of an error in my code?I have the following VARIABLES and FUNCTIONS:

<head>
var AmtSV;
var DelTimeCode="";

[code]....

View 6 Replies View Related

Preserve User-entered Quote Marks In Form Fields?

Apr 10, 2010

I have a JavaScript application that needs to preserve double quote marks and apostrophes (" and ') that are entered into form fields by the user. The form data is passed through several screens using hidden fields.

Right now, apostrophes work because I have the input fields coded as value="". I have not found a way for JavaScript to retrieve the field's value if double quotes are entered by the user. If I change the parameter to value='' (single quotes) then the apostrophes probably won't work.

Is there a straightforward way for JavaScript to retrieve the field value containing quotes, so that I can manipulate it into a different string that can be easily passed between HTML pages?

View 3 Replies View Related

DOJO Dialog Box - Remove Quotation Marks And Just Display The Pic - Words

Aug 4, 2011

As shown in the picture below, you can see the word "Chinese Swimming Club" in the dialog box

Why is the quotation marks there ?

Is it possible to remove the quotation marks and just display the pic + the words Chinese Swimming Club ?

Part of the coding:

Code JavaScript:

The name (Chinese Swimming Club) is retrieved from my database (I am using Microsoft SQL Server 2005)

View 4 Replies View Related

What Is The Purpose Of Writing A Function Inside Parentheses?

Apr 7, 2007

What is the purpose of writing a function inside parentheses?

PHP Code:

(function()
{
     var myvar = xxx;
     // my function code here....
}

)()

View 8 Replies View Related

Recursive Function Is (possibly) Writing Over Array?

Sep 16, 2010

Here's a simplified version of the function that's giving me trouble:

Code:
function saveArray(w){
var arr="['z',[";

[code]....

View 5 Replies View Related

Variable Declaration - Specify Arguments When Writing A Function

May 11, 2011

If you specify arguments when writing a function should you still declare the argument variable inside the function?

example:

Code:

or

Code:

View 8 Replies View Related

Writeln Function - Writing Some Words After Link

Aug 8, 2011

For example I have a link that I want to when I click on it, It writes some words after the link. I have written a code but it does not work as I want and it clears all the page and writes the words. I don't want to clear the page and write just words, I want to add words after the link.

Here is my code:
HTML Code:
<script type="text/javascript">
function a() {document.writeln('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');}
</script>
<a name="aaa" href="javascript:void()" onclick="a()">Click on me!</a>

View 1 Replies View Related

JQuery :: Writing Custom Tween (no Animate() Function)?

Sep 28, 2009

Is there a way to write a custom tweening function, preferably with easing, without the use of the build in animate() function?In Javascript, it's possible to do this with an interval, but I haven't been successful in finding something similar for jquery

View 1 Replies View Related

Writing Recursive Function - Return All The Permutations Of A Given String

Oct 29, 2009

I'm trying to return all the permutations of a given string, so I wrote the following recursive function:

The problem is, I'm not getting all the permutations, and I don't know why.

For example, if string="bindle", the output I get is:

And then the function stops.

View 4 Replies View Related

Writing A Function That Returns A String That Outputs A Branched Bulleted?

Jul 30, 2010

How would you go about writing a function that returns a string that outputs a branched bulleted list using <ul> and <li> tags of all the html elements in a page? The html elements don't all have id's or names, so I cannot reference them directly. I would like to do it recursively so that I can grab all the elements, not just those two or three levels deep.

[Code]...

View 3 Replies View Related

Not Defined Error - Writing And Approve/delete Function For A Website's Pending Memberslist In My ApproveMe

Mar 30, 2010

I've not been doing javascript too long and it's my first forray into AJAX so maybe a glaring error.

I'm writing and approve/delete function for a website's pending memberslist in my approveMe script firebug says doWork is not defined.

View 3 Replies View Related

Writing HTML In The <head></head> Of A Page With JS?

Dec 16, 2011

I know this can be done with media-queries in CSS3, After attaching the jQuery library, I used js to get the width of the window browser-viewport) and store that in a variable.

What I was aiming to do was write a <title></title> for the page and attach a stylesheet through <link /> using js only when the window's height was greater than 596px. So, I wrote the following:

Code HTML4Strict:
<!Doctype HTML>
<html lang="en">
<head>
<script type="text/javascript" src="../assets/js/jquery-1.5.1.min.js"></script>

[Code]....

View 8 Replies View Related

Call Script Function From Iframe.html To Control An Object On Index.html?

Aug 25, 2010

I'm building a webpage using javascript and iframes. Basically I have an iframe in the middle of the index.html page that links to another html page (let's call it iframe.html). My question is, is it possible to call a javascript function from iframe.html to control an object on index.html? If so, how do I do this? I'd like to be able to assign an image in iframe.html with the hyperlink of href="javascript:function()", where the function effects the CSS of a div on index.html.

View 2 Replies View Related

JQuery :: Call Back Function - Should The 1st Parameter Of The Get Function Be A HTML File

Jun 23, 2010

I have just started learning JQuery and have a doubt in the below code. $.get('myhtmlpage.html', myCallBack);The doubt is should the 1st parameter of the get function be a HTML file or can it be a unction name?

View 1 Replies View Related

HTML To DOM Function?

Mar 29, 2006

does javascript have a built-in
function that will take a string, parse any HTML tags from the string
and return back a DOM element representing the root of the HTML tree
represented by the string? For example is I called
HTML2DOM('<strong>foo</strong>''), it would return the 'strong' element
with one text element child with the value of 'foo'.

View 5 Replies View Related

How To Get Css / Html Into JS Function

Sep 4, 2011

how do I get the css and the html into the function?

View 2 Replies View Related

JQuery :: Add To Ul Using .html Function

May 13, 2011

I want to jquery to add to an <ul> list I have. The list already has one list item in it and I just want to carry on adding to it. I've tried copying some jquery html examples but I can't seem to get it to work. [code]but from what I understand, what you put in front of the .html is replaced with what you include after but that doesn't appear to be how this example is work. Also this adds to a div, can I not add to a li?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved