Get Context Path In Script Functions?
Nov 7, 2011I am trying to get context path of my Applcation. But it is showing errors in that. Can you please mention the way how to get context path in javascript functions.
View 4 RepliesI am trying to get context path of my Applcation. But it is showing errors in that. Can you please mention the way how to get context path in javascript functions.
View 4 RepliesI am running my website using Weblogic, so the path is something like
http://<myip>:<port>/<servername>/
On JSP pages I can use <%=request.getContextPath()%to get the root
path of the site, ie that specified above. How can I get the same using
Javascript?
For example, something like <a href='/home'>..</awill not work as
that would point to http://<myip>:<port>/home and needs to point to
http://<myip>:<port>/<servername>/home
I'm using a script to include images into a slide show using direct URLs to the image files, but I am using fckeditor (PHP) for my users to edit their content. The script in the .js file that pulls the images into the slide show.The user's image file is going to be named something like, "userImage01.php". Inside that file would be their image location path ~ "images/user/image1.jpg".Therefore, I need the above javascript to pull-in "userImage01.php" INSTEAD OF the image's location path.
View 10 Replies View RelatedI am building an sftp application. It has requirements to upload and download. To upload, a target folder that exists on the server needs to be set. I have a jQuery folder tree that dynamically creates a tree view of a directory on the server. Currently in Firefox, Opera, and Chrome if someone clicks on a branch of the tree on the afterClick event I am able to get the target path by using the DOM via node.context.nextElementSibling.value; The code for the afterClick is:
[Code]...
I know how to disable the context menu (the right hand mouse button) and how to replace it by my own menu. I also know that not everybody likes this - so let's not discuss about that here.
What I can't figure out and what I would like to know, is:
1) How to ADD elements to it, i.e. keep the original contents and add something to it;
2) How to RESTORE it to its original contents.
Does anyone know the code for a simple working example of these things?
I'm making a web application which is a copy of existing desktop application.
I use telerik controlls for MS visual studio I have a little bit complicated situation beacuse I need context menus but the main problem is that they have to be downloaded from server after the page loads. I can't load all of them on page because there are to many.
This is my solution of the problem. When user right-clicks js download from server through XMLHttpRequest some data from serwer and make menu from them.
But it needs much work to make the menu look nice, now I just have one level
menu.
I've been looking for some controlls that can do the things I need but with
no result.
I am creating html pages with forms where I use Dynarch menu script in a
context menu mode. Their script needs to be initialized like this:
<body onload="DynarchMenu.setup('menu', { context: true });">
This is in the beginning of the html page.
But, in my webpages I have only few pages where I actually use this kind of
menu. Since I use smarty template engine, I have single html-header file for
all pages - it includes the same <html><head><bodyetc. for each page.
So I tried to initialize this dynarch script only within the page that
actually uses this menu. I do it like this:
<form>[...]</form>
<ul id="menu">
[context menu elements definition here]
</ul>
<script>window.onload=DynarchMenu.setup('menu',{ context: true });</script>
This thing works OK in Firefox, however when I load such page in IE6 it
aborts the operation without even showing the page, and the popup message
says:
"Internet Explorer cannot open the Internet site http://example.com.
Operation aborted."
Does anyone know a way how to initialize the DynarchMenu.setup not from the
<bodyelement but from anywhere else in the html page?
I am writing a javascript code that parses dom and finds event
handlers attached to mouseover events. Then i will replace the
existing handler say B() with my own function say A(). When the event
happen and control comes to my function A(), after doing required
processing i will call B() as shown below
<a href = "abc.com" mouseover = "B();"link </a>
while parsing i will have (trimmed down version)
var oldHandler = node.onmouseover;
node.
function A()
{
/ * my code */
oldHandler.call(this);
}
This was working fine as long as B() was a global function. I started
getting problems when B was a member function. For eg:
function Alerter(text)
{
this.text=text;
var me=this;
this.invoke=function ()
{
alert(this.text);
}
}
var sayHi = new Alerter('Hello, world!');
The web developer would have code like
<a href = "abc.com" mouseover = "sayHi.invoke()"link </a>
But this time around, my function A() fails since although i have
handler to sayHi.invoke(), it has to be executed in correct context.
Other wise "this.text" is giving me error because when i say
oldHandler.call(this), i am executing the sayHi.invoke() with the html
element being passed as this.
I am trying to use Jquery as an XML tool to transform xml data other than the DOM.
This works very well and i can change my xml data.
Now i want back my whole xml that i just transform and this is where there is a problem !
$(xml).find('#id').html('some text').parent.parent.parent ... is not a good way
I read something about the defaultContext but it seems risky / hazardous.
Needed fonction would be $(xml).find('#id').html('some text').getRoot().html(); or something like that.
I try to usejQuery( html, [ ownerDocument ] ) to create a element and get the jquery object.
var $list = $('<ul class="list">');
console.log($list.context); // return undefined
$('body').append($list);
[code]....
I have a problem with YUI context menu. I want the menu to show different links (with product_id) in every row. I have been struggling with this for days no without result.My code is as follow:
Code:
$result = dbquery("SELECT ..........
echo "<table id='dataset' style='vertical-align: bottom' cellpadding='0' cellspacing='0' width='".$laius."' class='table11'>";
echo "<tr><td >TABLE HEADER</td></tr>";
[code]....
As you can see table row takes menu items according to id (type1, type2 etc).But as my table is created from mysql database dynamically, it does'n work that way.
opens a new window on the right side. resizes the main window. good for online help and
guided tours over multiple websites. still improving it....
I am displaying my own context menu in response to a right-click on control (textbox) in my ASP.NET application. In IE, I can suppress the display of the browser's own context menu by simply returning false from the javascript that displays my context menu.How can I suppress the browser context menus from Chrome or Firefox?
View 2 Replies View RelatedI want to add a context-menu to a button only. The aontext menu has to be dynamic one. it can be configurable.
View 1 Replies View RelatedAssuming I have an image in my page
I would like to invoke the 'save as' context menu for that image when the user left-clicks the image
I will have a link embedding the image. Clicking the link should invoke the menu and allow the user to save the image
Assuming I have 2 images. Image A and image B.
Image B is a small thumbnail version of image A
Image B is displayed on the screen
When the user left-clicks it, the 'save as' context menu should open (see previous question) and will allow the user to save image A (this is right, the original image and not the thumbnail being display)
Is this possible?
I have a TEXTAREA element. A user right clicks within in to get the context menu and they select "paste". I want my javascript code to know that they selected "paste". I know you can capture the mouse click, but can we capture exactly what event that attempted?
View 3 Replies View RelatedWhat is the evaluation context of the setTimeout args below? I have a separate Timer instance for each sprite in my program. As coded, "this.Clock" doesn't work.
/*================================================= ===
Timer.js
================================================== ==*/
function Timer(_sprite, _interval) {
var sprite = _sprite;
var interval = _interval;
var isRunning = false;
var timeoutID = false;
this.Clock = function() { // called after setTimout interval
if (isRunning) {
isRunning = sprite.OnClockTick();
if (isRunning)
timeoutID = window.setTimeout("this.Clock()", interval);
else
this.Stop();
}
}
this.Stop = function() {
if (timeoutID) {
window.clearTimeout(timeoutID);
timeoutID = false;
};
isRunning = false;
}
this.SetInterval = function(_interval) {
this.Stop();
interval = _interval;
isRunning = true;
timeoutID = window.setTimeout("this.Clock()",interval);
}
this.Continue = function() {
if (!isRunning) {
isRunning = true;
timeoutID = window.setTimeout("this.Clock()",interval);
}
}
}
--
Don't you see that the whole aim of Newspeak is to narrow the range of thought? In the end we shall make thoughtcrime literally impossible, because there will be no words in which to express it.
Is it possible to access the parent context within $.post to asign the result to the parent selection?
See this code here:
$("a[href='country#']").click(function(event) {
var dieBusinessUnit = 'THIS VAR SHOULD CONTAIN RESULT OF $("businessunit", xml).text())';
[Code].....
HTML:
How to find index-number of 'a' - element.
$('table tr td a').index() - always returns 0, but I need an index-number of link not in 'td'-element but in 'table'-element.
within a function for an onchange-handler ($(...).change(function(e) {...) i tried something like:
$(":parent input[name^=subsequentProperty]", this);
this does not work, but:
$("input[name^=subsequentProperty]", this.parentNode);
does work.
I recently started on a tree-folder display and used the Yahoo treeview control. Again it works very well and I am happy with the results. However, after seeing the treeview folder structure, my client asked if it would possible to add a right mouse click context menu to allow users to modify the folder tree -- add new folders, upload files, rename folders, delete folders, etc.
Updating the tree with the new elements is simple enough, but my attempts to implement the context menu have failed miserably. I have studied the Yahoo documentation and I can identify the name of nodes and the label of the element clicked on. But I can't figure out how to add the right-click code to the nodes the YUI Treeview generates.
I have successfully used various right-click Javascript scripts in the past -- but in those cases I was adding the function to an actual HTML element. The YUI elements are generated by the script, and I am at a loss as how to add the code to the generated node elements.
The application is part of a corporate intranet, and will only be used with Internet Explorer 6.0+ on Windows. The new context menu would completely replace the standard Windows context menu.
I am tempted to hack the YUI Treeview script to see if I can add a right click function similar to the Expand, Collapse and Clicked node functions, but I suspect that there is probably a simpler and easier way to do it.
[code]how i can set context/scope for myStartAction so it can access (this.url) variable?console.log(dd.url) will work but i can't predict what name will object have (that depends on user) there might be more than one instance of myObject
View 10 Replies View RelatedI'm trying to reuse some code in a different context to do a different job.The code to be reused contains hundreds of lines similar to a = new b.c.d(e,f) with different value for e and f.I need to create a new user defined object with the structure b.c.d. I've made numerous attempts along the lines of:
function d (e, f) {
this.e = e;
this.f = f;
}
[code]....
with various permuations of functional declarations.However I get error message "Object expected" or "b.c.d is null or not an object" at the final line of the example.It works with the test line var a = new d("test", "message") but not when I start to build up the expression.How should I define of b.c.d?
I have an outer page and an inner iframe. The outer page calculates some
javascript, and wants the inner frame to run it. The inner frame should hit
a page on the same (private) web server, so this is not a cross-site
scripting attack. But I would prefer not to taint the target page with any
extra logic to do this. (I will if I must.)
The calling page has these elements:
<script src="/javascripts/prototype.js" type="text/javascript" />...
<span id='update_me'>yo2</span>
<iframe id='grinder' src='sample.html' >
</iframe>
So here's most of the page which the iframe hits:
<script src="/javascripts/prototype.js" type="text/javascript" />...
<body bgcolor='silver'>
<span id='update_me'>yo</span>
</body></html>
Note that both the outer and inner page have a span with the same ID.
This question will resemble a JavaScript FAQ - how to evaluate Javascript on
the fly, or how to reload a JS file. The answers on the web generally do not
transport the JS across a frame boundary, so they don't address the bug I
encountered, and I can't tell if prototype.js or IE is at fault.
The outer page calls Ajax goodies that generate some JS looking like this:
Element.update("update_me", "here I B");
The page sends that, as a string, into this JS (in application.js):
function update_grinder(sauce)
{
var grinder = $('grinder');
if (grinder)
{
var doc = grinder.contentDocument;
if (!doc) doc = grinder.document;
if (doc)
{
evaluate(doc, sauce);
return;
}
}
document.write("your browser sucks");
}
So that contains enough logic to find the iframe's document, and it works
for Firefox, IE, Konqueror, and Opera. The code calls evaluate() with the
document where we need the evaluation context, and the string with our
source.
Here's evaluate():
function evaluate(doc, sauce)
{
var s = doc.createElement('script');
//s.defer = true; // <-- no effect
s.text = sauce;
var body = doc.getElementsByTagName('body').item(0);
if (body)
{
body.appendChild(s);
return;
}
body = doc.body;
if (body)
{
body.appendChild(s);
return;
}
}
That creates a <scriptblock, sticks our string in as its contents, and
pushes the block to the end of our <bodytag. Now here's the bug:
Firefox updates the inner <span id='update_me'>, and IE updates the outer
one.
If I remove the outer <span id='update_me'>, then IE simply can't find it
and throws an error. Even though it evaluates a script block clearly in the
context of the inner iframe.
I have tried calling the script from setTimeout, and from a button's onclick
handler.
Is there some script.aculo.us way to fix (yet another) bug in IE? Or is this
a bug in prototype.js?
code to disable right click menu when we right click on "a" tag. But it doesn't work on elements created on the fly. Do you guys know how to tackle this?
View 9 Replies View RelatedjQuery is ignoring the root element when passed through context. Am not sure if this is intended behavior.[URL]
View 7 Replies View Related