Search Results

Search found 147 results on 6 pages for 'mohammad kani'.

Page 5/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • jQuery DOM element creation vs innerHTML

    - by Mohammad
    While having one of my questions answered, cletus mentioned that when creating elements in jQuery it's better to use direct DOM element creation, instead of innerHTML. I tried googling it but I wasn't able to find a good article with comparisons. I've provided this code bellow as an example and I was wondering if someone could help me rewrite it in direct DOM element creation form in hope that i would also learn the difference afterwards. var img = $(this); img.append('<p class="cap"><a href="'+img.parent().attr('href')+'">'+ img.attr('title')+'</p></a>'); Thanks so much.

    Read the article

  • How to add dimensions to dynamic img elements

    - by Mohammad
    I use a Json call to get a list of image addresses, then I add them individually to a div like this. <div id="container"> <img src="A.jpg" alt="" /> <img src="B.jpg" alt="" /> ... </div> Unfortunately the image dimension is not part of the Json information but I do need them for later JQuery DOM interactivity. Do any of you JQuery geniuses know of a code that would flawlessly add the width and height to the individual image elements in the container after they load? I was thinking maybe the code could wait for the images to have a width bigger than 5px then add the new width and height to the element. But I wouldn't know how to go about that and make it work stably. Thank you so much!

    Read the article

  • How to scroll the horizontal scrollbar in an iFrame from the parent frame?

    - by Mohammad
    Is there any cross browser way to scroll the horizontal scroll bar of an IFrame with super wide content with Javascript inside the parent frame. Also I need it to be attached to the mouse wheel event. This is what I have so far, it's a bit copy and paste at the moment and doesn't work unfortunately. //var myIframe = document.getElementById('iframeWithWideContent'); //myIframe.onload = function (myIframe) { var mouseWheelEvt = function (e){ var event = e || window.event; if (document.body.doScroll){ document.body.doScroll(event.wheelDelta>0?"left":"right"); }else if ((event.wheelDelta || event.detail) > 0){ document.body.scrollLeft -= 10; }else{ document.body.scrollLeft += 10; } return false; } if ("onmousewheel" in document.body){ document.body.onmousewheel = mouseWheelEvt; }else{ document.body.addEventListener("DOMMouseScroll", mouseWheelEvt); } //}? I probably should uncomment that code, replace document.body with myIframe though I wouldn't know what I'm doing wrong. Demo on JSBIN link fixed Any help from you JavaScript Lords would be very appreciated. Thank you!

    Read the article

  • Rendering PDFs from a database inside MVC views?

    - by Mohammad Sepahvand
    I was wondering if it's possible to do this without using 3rd party compnents in MVC 3. (I am open to free components though.) There are a couple of links out there but they seem to be mostly concerned with reporting and other code samples that do claim to do this sort of thing don't seem to compile. I'm not having any trouble saving and retrieving the PDFs to and from my database, but when I return the PDF as a File or a FileStreamResult the user is prompted with a download. A more desirable approach would be to actually render the PDFs inside the browser. I've had a look at iTextSHarp, it does the job to an extent, but it's not a complete solution. For example it will display the PDF inside the view if and only if the client has Adobe Reader installed, otherwise it prompts for a download. So technically, I'm mostly looking for a PDF viewer. Any ideas?

    Read the article

  • Alternative to before </body> tag inline Javascript

    - by Mohammad
    I know inline Javascript is frowned upon and with the new on-the-fly Javascript compressors that check for idle/unused function usage and omit the unused code, it seems good practice to have all your Javascript in an external file. My question is, in situations like FOUC (flash of unstyled content) which usually require little snippets of code right before the closing </body> tag, is there a JQuery resolution that would serve the same purpose, but from a remote Javascript file linked in the <head> of the document?

    Read the article

  • Why build Javascript functions as JQuery plugins?

    - by Mohammad
    I've seen alot of JQuery implementations of existent JavaScript functions that merely wrap the JavaScript code in a JQuery wrapper and don't actually rely on any of JQuery's base for their operation. What are the benefits of using Javascript as a JQuery plugin? If there are none is there a speed loss to use a JQuery plugin that could have easily been implemented outside the wrapper just as well? Many thanks in advance (just trying to learn something here).

    Read the article

  • Regular Expression question

    - by Mohammad Kotb
    Hi, In my academic assignment, I want make a regular expression to match a word with the following specifications: word length greater than or equal 1 and less than or equal 8 contains letters, digits, and underscore first digit is a letter only word is not A,X,S,T or PC,SW I tried for this regex but can't continue (My big problem is to make the word not equal to PC and SW) ([a-zA-Z&&[^AXST]])|([a-zA-Z][\w]{0,7}) But in the previous regex I didn't handle the that it is not PC and SW Thanks,

    Read the article

  • Reuse implemented business classes in a web applications

    - by Mohammad
    I have implemented my domain layer classes and i have used them in a java application. Now i want to use same classes in a java web application,but i dont know how can i do it? In the java aplication we make and run some objects in main(class and method) and use them while program is running. for example an object that hold a collection of data that will be needed for all user requests. My question is: How can i create and hold such objects and data that should be available for all users and clients.

    Read the article

  • How to call JQuery functions

    - by Mohammad
    Hello, I was wondering about the different ways of using a JQuery function on a variable like I know this one $.DoThis(variable); but is there a way to call it at the end like normal Javascript functions variable.$.DoThis(); haha I know this sounds stupid but I need to ask somewhere. Thanks!

    Read the article

  • is jQuery 1.4.2 compatible with Closure Compiler?

    - by Mohammad
    According to the official release statement version 1.4 has been re-written to be compressed with Closure Compiler yet when I use the online version of closure compiler I get 130 warnings. This is the code I use. // ==ClosureCompiler== // @compilation_level ADVANCED_OPTIMIZATIONS // @output_file_name default.js // @code_url http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js // ==/ClosureCompiler== And as far as I know you get the real benefit of Closure Compiler if you include the library with your code also, so it removes the unused functions. Yet my testing show that I can't get any further than compressing the library itself.. What am I doing wrong? Any kind of insight will be much appreciated.

    Read the article

  • Forcing images to not wrap

    - by Mohammad
    I can't touch the html theme but I have access to the css files. <div class="photos"> <img src="a.jpg" alt="" align="left" /> <img src="b.jpg" alt="" align="left" /> <img src="c.jpg" alt="" align="left" /> //align makes the images wrap </div> Unfortunately I can't remove align="left" from the images otherwise this CSS snippet would have done the job .photos{ white-space: nowrap; } .photos img{ display: inline; vertical-align: top; } Any ideas? Is it even possible to make these images line-up horizontally without using the force of a table and only with CSS? Many Thank in advance!

    Read the article

  • problem in letter's language.....

    - by mohammad
    Hello... I have a problem after i setup windows 7 all old projects in c# vs 2005, the letters that written in arabic changed to a strange language and i changed the language's settings in control panel to arabic then the new projects passed but the old projects have the same problem

    Read the article

  • Help with writing a php code that repeats itself per array value

    - by Mohammad
    Hi I'm using Closure Compiler to compress and join a few JavaScript files the syntax is something like this; $c = new PhpClosure(); $c->add("JavaScriptA.js") ->add("JavaScriptB.js") ->write(); How could I make it systematically add more files from an array lets say for each array element in $file = array('JavaScriptA.js','JavaScriptB.js','JavaScriptC.js',..) it would execute the following code $c = new PhpClosure(); $c->add("JavaScriptA.js") ->add("JavaScriptB.js") ->add("JavaScriptC.js") ->add ... ->write(); Thank you so much in advance!

    Read the article

  • Screen Resolution Problem In WPF ?

    - by Mohammad
    I'm gonna detect the resolution with the following code in WPF : double height = System.Windows.SystemParameters.PrimaryScreenHeight; double width = System.Windows.SystemParameters.PrimaryScreenWidth; Current resolution of my screen is 1920*1200, but height is 960.0 and width is 1536.0 !!! What's wrong with it ? Thanks in advance.

    Read the article

  • Help with manipulating child/parent elements with jQuery

    - by Mohammad
    Currently I have this JQuery script var img = $(this); img.wrap('<div class="photo"></div>'); img.parent().append("<p>" + img.attr("alt") + "</p>"); which successfully turns the following: <img src="photo.jpg" alt="caption"> into this <div class="photo"> <img src="photos.jpg" alt="caption"/> <p>caption</p> </div> All is well unless the image has a link as a parent; <a href="#"><img since I want it to be correct html (I'm fussy) improving the resulting outcome bellow would be satisfactory <a href="#"> <div class="photo"> <img src="photos.jpg" alt="caption"/> <p>caption</p> </div> </a> to this: <div class="photo"> <a href="#"> <img src="photos.jpg" alt="caption"/> </a> <p><a href="#">caption</a></p> </div> </a> This is my jQuery script so far (which doesn't work bc I'm a noob) aha if(img.parent('a')){ var targetLink = img.parent('a').attr('href').val(); img.parent('a').wrap('<div class="photo"></div>'); img.parent('div').append('<p><a href="'+targetLink+'">' + img.attr("alt") + '</p></a>'); }else{ img.wrap('<div class="photo"></div>'); img.parent().append("<p>" + img.attr("alt") + "</p>"); }; Any advice, or help will be greatly appreciated : ) Thank You! Update *Answer* (works but looks sloppy) I'm editing it atm; if(img.parent('a').length){ var targetLink = img.parent().attr('href'); img.parent().wrap('<div class="photo"></div>'); var divTarget = img.parent('a').parent('div'); divTarget.append('<p><a href="'+targetLink+'">' + img.attr("alt") + '</p></a>'); }else{ img.wrap('<div class="photo"></div>'); img.parent().append("<p>" + img.attr("alt") + "</p>"); };

    Read the article

  • Javascript code semantics

    - by Mohammad
    if(myVar = img.parent('a').length > 0){ var Y = 1; }else{ var Y = 2; } When I run this code myVar (being announced for the first time) takes the value of img.parent('a').length > 0 and becomes either false or true depending on the case. First Question: Is this a correct way of defining myVar? Second Question: Am I defining Y for the second time? Is my second 'var' excess? i.e. should i just write Y = 2;

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >