Make The Function "sistaefternamn" Easier / Simpler
Aug 4, 2010how i can make the function "sistaefternamn" easier/simpler. And an explenation of the simplification would be nice. Here comes the code.
[Code]..
how i can make the function "sistaefternamn" easier/simpler. And an explenation of the simplification would be nice. Here comes the code.
[Code]..
These are a couple little bookmarklets that make testing your pages easier.
This is for adjusting resolution.
<script>
javascript:external.AddFavorite('javascript:void(m=window.open("","m","height=30,width=150"));m.focus();m.document.write('<form><select onchange="opener.eval(this[this.selectedIndex].value)"><option value=""><option value="self.resizeTo(640,480)">640x480<option value="self.resizeTo(800,600)">800x600<option value="self.resizeTo(1024,768)">1024x768</select></form>')','Resize')
</script>
This is for running selected code. You select the code then open the bookmark. (I used it testing this post.)
<script>
javascript:window.external.AddFavorite('javascript:void(window.open("javascript:document.write(opener.document.selection.createRange().text);document.close()"))','Run Code Selected')
</script>
Turn borders on to see table layout.
<script>
javascript:window.external.AddFavorite('javascript:void(t=document.getElementsByTagName("table"));for(i=0;i<t.length;i++){void(t[i].border="1")}','Borders On')
</script>
I use them regularly hope they're usefull to you.
sometimes simple href:
Code:
<a href="javascript:history.back(1)">Back</a>
or
<a href="index.jsp">Home</a>
takes an almost long, about 5 seconds for loading or even so, to operate.
Could you tell me of the reason and also of possible different suggestions.
a common task when writing multi-use functions, is deciphering the type of data passed to the function.
Javascript's built-in data identification methods complicate function writing, by imposing a "20 questions" style interogation to determine the actual, useful to a programmer, type.
they also slow down functions, requiring both a function execution and a comparision operation upon every type guess.
a common method is something like:
if(typeof x=='string'){ };
but this has several limitations. for example:
x=[1,2,3];
typeof x; //returns 'object'
safely catching an undefined is often done like:
if(typeof x != 'undefined' ){ };
my function making got a lot easier after writing these simple prototypes:
String.prototype.type="string";
Array.prototype.type="array";
Number.prototype.type="number";
Boolean.prototype.type="boolean";
Date.prototype.type="date";
Object.prototype.type="object";
RegExp.prototype.type="regexp";
Function.prototype.type="function"
if(!!window.XML)XML.prototype.type="xml";
String.prototype.isString=1;
Array.prototype.isArray=1;
Number.prototype.isNumber=1;
Boolean.prototype.isBoolean=1;
Date.prototype.isDate=1;
Object.prototype.isObject=1;
RegExp.prototype.isRegExp=1;
Function.prototype.isFunction=1;
if(!!window.XML)XML.prototype.isXML=1;
the result?
shorter simpler code.
examples:
// smarter object typin':
[1,2,3].type; //returns 'array'
//when expecting a string or array possibility:
y=x.isString?x:x.join();
//more-flexible event handling:
function doBold(elm){ //accepts element object or id string...
if(elm.isString){elm=document.getElementById(elm);}
elm.style.fontWeight="bold";
}//end doBold
// detect an undefined variable:
if( ! x.type){ alert('x is undefined')};
by tucking the protos in your script file, you get simpler, faster-executing code. (for a tiny bit of overhead)
if script length is of upmost concern (as in a bookmarklet), these smaller protos give you simpler typing: (without the speed benefits...)
Object.prototype.type=function(){return typeof this;};
//usage:
switch(x.type()){
case 'string': return x;
case 'date': return x.toLocaleString();
case 'array': return x.join('
');
default: return x.toString();
}//end switch;
//another one:
Object.prototype.isType=function(strType){return (!! typeof this === strType)};
//usage:
x=101;
x.isType('string'); //returns false
x.isType('number'); //returns true
I tried using the "For Loop" function to accomplish this but I couldn't get it to work. show me an easier way to shorten this code up
Code:
function normal()
{
var welcomelink = document.getElementById("welcomelink");[code].....
I did try to recode everything so that the link/content and sublink/content would follow a numerical sequence...e.g. link1/content1, link2/content2, link3/content3, sublink1/subcontent1, sublink2/subcontent2, sublink3/subcontent3...etc. and then use the for...loop function but again it failed on me.
I have a js script that changes the visibilty of a selected span to "visible", but makes sure that no other related spans are visibile to the user by hiding everything first....
View 1 Replies View RelatedI have a real perplexing issue. In two separate "projects" I had code that displayed checkboxes - when clicked, they would fetch information from a db and display it in the div below. I had code that displayed a jquery date-picker - when clicked, it would fetch information from a db and display it in the div below. My issue comes with this:
[Code]...
How would you make a function trigger a other function?
View 10 Replies View RelatedI have a slide show program. First theres stuff to set up the array, and the time between slides Then a function startIt()is defined then a function stopIt()
Then two buttons, Start and Stop, which when pressed call the relevant
functions.
When the page loads, you have to click the Start button to get the
slide show running, but I'd like it to start running straight away
without having to click. I can't for the life of me figure this out.
I thought it was just a question of putting the line
startIt(); Code:
Is it possible to make a variable available to other functions outside a function So to make it global from within a function without using a callback
function() {
var something = 'hello';
}
function(something) {
document.write(something);
}
something like that possible??
I Have to sets of Radio buttons like so:
<input type="radio" name=p1 value=1>
<input type="radio" name=p1 value=2>
<input type="radio" name=p1 value=3>
<br>
<input type="radio" name=p2 value=1>
<input type="radio" name=p2 value=2>
<input type="radio" name=p2 value=3>
then a text area and a button:
<input size=7 name=total>
<input type="button" onclick=c()>
the function checks for the radio buttons then outputs its value in text
area.
<script type="text/javascript">
function c()
{if (p1[a].checked&&p2[b].checked)
total.value=parseFloat(p1[a].value)+parseFloat(p2[b].value)
}</script>
my question is what is the possibility of giving values to a and b such as
all radio buttons can be covered, is there a way to do this without having
to output all cases with else if structure.
I'm new to jQuery, but learning fast, and loving the new functionality!I'm using a Flash upload component that all works fine, and once it's complete (file uploaded) it calls function.I'm running the Flash upload in a modal (nyroModal - very cool!). The link below does what I need it to do - navigate to a new page and re-size the modal:<a href="test2.aspx#blabla" class="nyroModal">Ajax Filtering Content #test</a>What I need to work out is how to make the JS function above work in the same way as this link. I know very little JS, but I think the 'class="nyroModal" needs to be part of the link in the function some how??
View 3 Replies View RelatedThis question applies to javascript generally as opposed to jQuery specifically. I want to be able to structure my scripts into classes, then create them using the "new" keyword, but here is the important bit: How do I make a js function private (or public for that matter)?
View 4 Replies View RelatedObviously I'm not quite understanding .not() because the following code does not perform identically:
if(!$(this).is('.current')) { some code }
and
if($(this).not('.current')) { some code }
So that I can make use of .not(), how would I write the second conditional so that it performs as the first conditional?
I have a pretty simple function set up to pull XML data into my page, but there's a couple things wrong with it. I'm REALLY new to J Script and really trying my best to learn, but for some reason I'm not yet adept at googling the right results :rolleyes:At the very bottom you can see the data from the first XML entry, so it seems the function itself is working fine, but it's not looping coorectly to access all the data.Also, I want to pull it into the "shows" div of the page, but can't figure out how to put it there (seriously, I am very new with JS). The code below is not working, but the live site has it added to the body, which does show the one entry.Here's the XML function, the XML data and the HTML markup:
Shows function -
function loaddates()
{
var xmlData = document.getElementById("tourdates");
var newDates = xmlData.getElementsByTagName("dates");
[code]...
How do I make a variable global so that all other functions can use it.But it is declared inside the function test()
View 3 Replies View RelatedDoes anyone know how to make the cycle function in jquery unobtrusive?
I've got the following code and when I disable javascript, I get a nasty long list of images :(
Jquery code:
Html code:
I have been making a javascript dice throwing app(? or whatever it's supposed to be called), but can't figure out how to make 2 functions for one button. I'm trying to have both of my dice (6- and 20-sided) to be controlled by the same throwing-button, but have radiobuttons to decide which one to throw.
[Code]..
I have a function that I'm trying to modify. It adds an element to the page. The problem is, I require that ClickGeocode() finishes executing before the rest of the code in the function completes. Currently that is not the case..
Event.add(window, 'load', function()
{
Event.add('addressSearch', 'click', function()
{
ClickGeocode();
[Code].....
I have made a javascript image viewer where there are thumbnails at the top and when you click on them the bigger image below the row of thumbnail image changes accordingMy question is, how do i make the larger image become a hyperlink to the corresponding page it represents. Alternatively, it would not be a problem if a caption could be displayed below which i could make into a hyperlink.Here is my script .js file
function img1click() {document.IMG.src="imagelibrary/dazzlebig.jpg";}
function img2click() {document.IMG.src="imagelibrary/gunshotbig.jpg"}
function img3click() {document.IMG.src="imagelibrary/searoombig.jpg"}
[code]....
I have below code to create two ajax requests. When ajax requests fetched, they alert the related request number.
Code JavaScript:
function ajaxIt(url,num){
var req = new XMLHttpRequest();[code]....
why removing var phrase overwrites requestNum value for two different asynchronous functions? How can I make sure variables are not overwritten by different function calls?
How can I make my alert work? Right now it is undefined and I need to make my function in the variable global. Can this be done?
Code JavaScript:
I'm trying to make a function that will enable any given form field. This is what I have, my form name is 'searchfields':
Code:
function EnableDisable(field)
{
var loc = 'document.searchfields.'+field;
loc.disabled = false;
}
Is it possible to make a variable inside a function global (or at least usable in other functions)?
View 2 Replies View RelatedCode:
<script>
var timer = 0;
function SpellItOut(word)
{
[code]....
how do i write this in a stand alone javascript
<input type="button" name="sendToFlash" id="sendToFlash" value="Send Text To Flash" onclick="getElementById('flash').sendTextFromHtml(htmlText.value + htmlText.value); document.getElementById('htmlText').value = ''" />
</form>
i need to make a function that will be executed when they click on onclick