|
I seek treatment can be done either on the server side (C) or client side (JavaScript)
|
|
|
|
|
Hi all, I am trying to create a web editor using an Iframe. So basically users can open up a page they want to edit in the Iframe and edit away.
I want to be able to grab the content of any element of a page and then do what I need to with it. I ran into some problems when there are elements embedded in other elements such as a div with children each having no id or class attributes.
I tried to solve this problem by first identifying which element was clicked and give it a temporary id if id did not already have one. Then using the new id get the content (I'm trying to get the text). I tried to implement that idea using the code below but it did not work.
$('#myiframe').load(function () {
$(this).contents().find("body").on('click', function (event) {
var a = event.target.tagName;
var divContent = $("#myiframe").contents().find(a);
$(divContent).click(function (e) {
var ClickedElementID = e.target.id;
if (ClickedElementID == "") {
e.target.attr('id', 'tempID');
var myText = $('#tempID').text();
$('#tempID').removeAttr('id');
}
else {
var myText = $(ClickedElementID.text())
}
});
}
}
Please help me make the code above work as I intended, thanks in advance.
modified 22-Nov-14 19:12pm.
|
|
|
|
|
You already have the element, so you shouldn't need to give it an ID. Try:
$(divContent).click(function (e) {
var myText = $(e.target).text();
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi everyone!
I have java web app. And when user logged in on his profile I need to show his location on google-maps using his GPS coordinates, that I retrieved from JSON file.
I've never used javascript, html and css. Could anyone please suggest how to sort this out
Thanks in advance!
modified 19-Nov-14 2:40am.
|
|
|
|
|
Well, this depends on what exactly you want to do.
-How I have done it often is , send a xml or json object when you send the page back to the client. save that json object in may be a javascript variable or a hidden field. write a small parser to fetch data out of this json data structure and provide it to the built in Google Maps library. The library is open source so you can definitely do what ever customization you want to do over it. Be sure of which Google Map library version you are using. You will find a lot of difference in older and newer versions of google map library.
Check the following two links where I used same Google Map client side library to give two different views:
http://www.lalsgroup.com/store-locator.aspx[^]
Click on the radio buttons on the left to select a brand, once you select a brand you will see stuff happening on the map
On this same website, go on the following link and expand the 'Location Map' panel.
http://www.lalsgroup.com/contact-us/[^]
Google map client side API uses js module pattern, same as jQuery plugin-if you know what I am talking about. You need to pass in a initial configuration object, where you can do different defaults, one of them is to setup up initial location. You actually have to pass in default latitutde and longitude and several other config defaults if you want.
Google for 'storeLocator jQuery store locator plugin', you will find a lot of stuff over it.
Hope thats the answer to your question.
Thanks.
Good day!
|
|
|
|
|
Does anyone know a JavaScript library that includes good functions for parsing URL's into their component parts?
Specifically, I would like to extract a query variable from the first URL and use it to construct a new URL.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Thank you!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello,
This is my first post to CodeProject. Please excuse if I commit some CodeProject "nono's," but point them out if you wish.
Anyways, I need help. I have only ever used <script> </script> in an html document to add functionality to a web page. But, I was recently given the task of implementing all of my JavaScript work from an outside .js file.
Here is what I know. I know I'll have to create and external .js file, and link it from my html. But what should it look like? I've never worked with raw JavaScript files before.
Here is my code:
<form name="myForm"> <!--
<fieldset id="inputs"> <!--
<ul> <!--
<li>
<label for="principal"> Principal(p): </label>
<input type="number" id="principal" name="principal" min="1" max="1,000,000"> <!--
</li>
<li>
<label for="intRate"> Yearly Interest Rate(r) (Enter as a decimal): </label>
<input type="text" id="intRate" name="intRate" placeholder="0.00" min="0" max="1"> <!--
</li>
<li>
<label for="length"> Loan Length(years): </label>
<input type="number" id="length" name="length" min="1" max="100">
</li>
<li>
<input id="clickme" type="button" value="Your Monthly Fate" onclick="loanPayment()"> <!--
</li>
</fieldset>
<fieldset id="output">
<li>
<input type="text" id="result" name="result">
</li>
</fieldset>
</ul>
A pretty standard form with some amateur comments. This all would normally go in the body of my html doc. Next, here's the function and variables within the <script> tags of the head:
<script>
function loanPayment()
{
var principal = document.getElementById("principal").value;
var intRate = document.getElementById("intRate").value;
var length = document.getElementById("length").value;
var R = intRate/12;
var Y = length*12;
var W = Math.pow((1+R),Y);
var F = (R * principal * W)/(W - 1);
F = F.toFixed(2);
document.getElementById("result").value = "Monthly Fate = $" + F;
}
</script>
How would this form be implemented into an html web page through the use of an external .js file? I'm very new to html/css/JS and I want to get it right. Thank you all and please try to be as detailed as possible; what's common sense to you might not be to me.
|
|
|
|
|
|
I began to develop addon for firefox and I had a problem.
var tabs = require('sdk/tabs');
tabs.on('ready', function (tab) {
tab.attach({
contentScript: "alert('azaza');",
onMessage: function(message) {
console.log("message");
}});
}
When I try to execute this code in Firefox nightly 36 it says "TypeError: window is null", but in Nightly 32 it works fine! In last fierfox (not nightly) this code not working too.
I tried to execute this code in nightly's browser debugger console, but the same result (window is null).
Help me, please.
|
|
|
|
|
|
Need to modify code to give PRODUCT of array
function start()
{
var theArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
var total1 = 0, total2 = 0;
var length = theArray.length;
for ( var i = 0; i < length; ++i )
{
total1 += theArray[ i ];
}
var results = "<p>Total using indices: " + total1 + "</p>";
for ( var element in theArray )
{
total2 += theArray[ element ];
}
results += "<p> Product using indices: " + total2 + "</p>";
document.getElementById( "output" ).innerHTML = results;
}
window.addEventListener( "load", start, false );
modified 16-Nov-14 19:18pm.
|
|
|
|
|
Member 11238538 wrote: Need to modify code to give PRODUCT of array Very interesting, now do you have a problem using multiplication?
|
|
|
|
|
Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have few article in PDF File. I want to set HTML Code into my pdf file for upload in my video Production Sarastoa. Can you give me information how can I set HTML Code for every PDF file?
|
|
|
|
|
I have a jQuery plug-in that set the date and time text into a HTML span. See the code below. How do I store the text in the span into the value of a text box?
$('#widgetCalendar').DatePicker({
flat: true,
format: 'd B, Y',
date: [new Date(now3), new Date(now4)],
calendars: 3,
starts: 1,
onChange: function(formated) {
$('#widgetField span').text(formated);
}
});
What I have tried is to set the span style="display:none" and used a textbox to receive the date which does not work:
<span style="display:none;"><asp:TextBox id="MyHiddenTextBox" runat="server" /><span>
Thanks,
Steve
|
|
|
|
|
To set the value of a text box, you need to use the .val(...) method[^], not the .text(...) method.
Your first call to .text(...) is replacing the text of all <span> elements within your widgetField element. Since you've wrapped the text box in a <span> tag, it will be destroyed by that call. You'll either need to be more specific with your #widgetField span selector, or remove the <span> which surrounds the text box.
Also, if you're using a master page, the name of your text box won't match the ID attribute set on the server.
<asp:TextBox id="MyHiddenTextBox" runat="server" style="display:none;" />
onChange: function(formatted) {
$('#widgetField span').text(formatted);
$('#widgetField input[name$=MyHiddenTextBox]').val(formatted);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Every one,
i have recently started working on IE 11 migration work (Earlier the project is hosted by IE 7). i'm new to Jquery/Ajax. want to know what are the common issues that we might face when we host the webapplication in IE 11 rather than old browser IE 7.
|
|
|
|
|
By and large, you can continue to use the same code that you previously had in place by making sure that your markup targets the appropriate versions of HTML, and that you set a meta http-equiv="X-UA-Compatible" tag for IE-7. This will force compatibility mode where appropriate.
That said, in terms of modernizing your application base you will be pleasantly surprised, I think. HTML5 comes with way fewer hurdles than previous versions, and you'll find native support for things that you previously needed to do all kinds of JavaScript and CSS hacks to achieve. Provided that you maintain production code, you'll find that the focus is moving from a monolithic back-end with a slim client side to treating the browser as a UX/business layer and the servers simply provide the data layer. That's the modern paradigm, and it changes greatly where the focus is in terms of coding.
I would say that your biggest hurdle will be properly implementing and sticking with a security policy. The move of state and processing to the client side has resulted in more frequent dialog between clients and server, and if you don't validate that dialog properly you can expose serious vulnerabilities in your application.
After that, switching focus from your back-end of choice to JavaScript (and the menagerie of frameworks available for it) will be a learning curve, but not a terribly difficult one as long as you can keep a hold of what's happening at each processing stage.
At any rate, best of luck, and I promise you that after a little wadding through the learning curve, you will love the new technologies.
|
|
|
|
|
var a = [{"Id": 1, "Name": 'a'}, {"Id": 2, "Name": 'b'}, {"Id": 3, "Name": 'c'},{"Id": 4, "Name": 'd'},,{"Id": 5, "Name": 'j'}];
var b = [{"Id": 1, "Name": 'a'}, {"Id": 4, "Name": 'd'}, {"Id": 5, "Name": 'j'},{"Id": 9, "Name": 'i'}];
I need to remove duplicate in "a" by comparing "a" with "b" using underscore js
|
|
|
|
|
You need to post the code you have and then show us where you are stuck.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Sorry, but is that supposed to be a question?
|
|
|
|
|
Hi, I would like to add a link from the browser which opens a video in the VLC application that everybody has installed here.
Is there a way of doing this in HTML or JavaScript?
|
|
|
|
|