Where To Put Page-specific JavaScript
Feb 26, 2007
I have a little menu system which essentially takes HTML like:
<div id='foo'></div>
and retrieves foo.shtml from the server and inserts it inside the
<div>. But sometimes I'd like foo.shtml to look like:
<script language='JavaScript'>
...do something AJAX-y
</script>
<div></div>
so that the script fills in the page. I've hacked together something
that inserts the foo.shtml into foo's div then does a
fooDiv.getElementsByTagName('script') and uses eval() on them and it
works most of the time in some brossers but it seems hackish and
somewhat dangerous and it doesn't work everywhere. Surely there's an
AJAX idiom (or even a DOM built-in) to execute scripts as parts of
pages load.
View 22 Replies
ADVERTISEMENT
Jun 29, 2007
I just wanted to get your opinions on this: I have several pages with page-specific JavaScript (i.e. script I know cannot be reused...it can only be run against elements found only on that page).
My question is, would you recommend just putting it in SCRIPT tags in the header, or should I create thispage.js so that the code is separated into another file? It slows the request because the browser has to ask for another external file, but keeps code out of the HTML doc.
View 5 Replies
View Related
Mar 10, 2010
<div class="box top"></div>
<div class="box main">
<div class="box header">
<div class="badge"><ul><li class="active"><span>60</span></li></ul></div>
[Code]....
What is happening is $(this) is no longer based on .expand being the (this) that is clicked.
like if i have a button SOMEWHERE randomly on the page with this
<div onclick="Minimize('_alerts');">Click Here</div> this will minimize alerts but because the (this) in minimize function doesn't actually point to the right button that I want to add a class to.
Is there a way to modify the minimize function so that it finds the <div id="mytoggle"><ul> <li class="expand boxminimize" rel="_alerts"> using the rel toggle, and then changes the class of the li from expand boxminimize to boxexpanded??
just like the .expand click function I posted on the top of the post that works?
View 1 Replies
View Related
Mar 29, 2011
It is possible to perform a find in page search that looks at a specific link, opens the page in a new window and finds the text within that document?? Basically I regularly use an html page in work that has a list of people and their telephone numbers. I want to be able to type in a searchbox on my main page and it open the target page and find the name I am looking for? Is this possible or can you only Find In Page on the same page or another frame?
View 1 Replies
View Related
Jul 19, 2010
My goal is to load the JS for a specific element before displaying that element. I integrated a third part script, and it works well. I set the timer here:
The JS is in my heading as <script type="text/javascript" src="countdownpro.js"></script>
About mid-body I have: <span id="countdown1">2010-07-20 00:00:00 GMT+00:00</span> which allows for the setting of a target date to countdown to.
When the page first loads it shows the above long format target time, until the js/meta tags kick in to modify it to just show the actual countdown as 00:00:00.
I have attached countdownpro.js to this post. I tried shifting the function CD_Init() to the top of the script, and also appended it inline with the .html. I tried setting the big external script to "defer", but neither arrangement worked. I also tried placing the src file right at the top.
View 2 Replies
View Related
Nov 5, 2003
Code:
document.getElementById('hello').style.border-top = "2px red solid";
What I'm trying to do is just change the top border color of something I defined with css. The code above of course didn't work.. heh. How would I do it?
View 21 Replies
View Related
Jul 23, 2005
I have a popup window which is a slideshow of about 7 images. When the
popup window loads, the first image is present and then the viewer can
select next or previous to scroll through the rest of the images.
I'd like to use the same popup window at different points throughout
the website and have the Virtual Tour (slideshow) open up at the
appropriate photos. Meaning I'd like to control which picture the
popup window opens up to, depending on where the user is in the site.
Does anyone know where I can find code that does this? I am somewhat
familiar with Javascript but would like to find some ready-made code
which accomplishes this.
View 2 Replies
View Related
Nov 4, 2004
I'm trying to call a specific function in an external javaScript file:
<script src="myCode.js" type="text/javascript"></script>
How do say I just want a certain function to run. I'm using this:
<script src="myCode.js:certainfunction()" type="text/javascript"></script>
but it's not working, any ideas?
View 3 Replies
View Related
Mar 21, 2006
Does anyone know a simple cross-broswers vertical scrolling javascript
that can call up its scrolling contents off an external html page/file?
View 1 Replies
View Related
Feb 28, 2011
I have to go back to specific page(html page) using backspace button in javascript n html.
View 4 Replies
View Related
Nov 10, 2010
I have a slideshow on the "Projects" page. The javascript is external.
There's a link on the homepage that when clicked needs to open the Projects page with the appropriate slide loaded. How do I do that?
Here's the code I have for the slideshow code...
View 1 Replies
View Related
Jul 31, 2008
Does anyone know if there are any ajax functions that would allow me to pull certain content from one page and display on another in a named <div>?
I currently have some code that pulls all the content and works very well. I am looking to enhance this to say only pull the first <div></div> content.
View 3 Replies
View Related
Dec 4, 2010
just needed to know this because I'm setting the path of the cookie and the path on my browser isn't matching what I set it as.
var the_cookie="file_address~"+x+";path=gallerylogin.php";
...it still doesn't set it so "gallerylogin.php" can access it.
View 1 Replies
View Related
May 20, 2011
I have created a very very simple javascript that displays random text quotes. It is in Greek but here it is anyway: [URL]. It is in blogger and shows up as a gadget. My problem is that I need to make it reload by a button and at the same time go to the top of this gadget (using an anchor). The reason I want to do this is that I have been sharing this with other bloggers, but if they don't put it on top of their page, as soon as they press the button that reloads the page, they are in the top of the page and they would have to scroll down to find the quote.
I have tried to use window.location.reload with window.location.hash.
It works in Firefox, but not in IE.
I have been trying something like that:
<input type="button" value="Click to refresh" style="width: 130px" onclick="window.location.hash='#something';window.location.reload()" />
As I said, this works with Firefox, but not with IE9
Also, I can't define urls beforehand because I want other people to be able to use it to their own blog or website.
View 1 Replies
View Related
Jun 13, 2011
I am using a dropdown box with 6 options. On change I want ajax to return part of an HTML/PHP page that corresponds to one of the 6 questions. I was trying to put and if statement on the return page to determine the part that I wanted but I didnt work. I rather not create 6 HTML/PHP files for each of the options. Here is part of the CODE
CREATE A:
<select name="mychoice" onchange="onchange_getform(this.value)">
<option>----Select----</option>
[code]....
View 4 Replies
View Related
Apr 20, 2009
I have a pdf document toolkit.pdf (202.81K)Number of downloads: 81 that serves as a home page or table of contents for reference materials. This is NOT a web-based document. We use this as a reference tool in a face-to-face classroom setting. Each item on the list or table of contents is a button that the user clicks on to see a dropdown menu of reference documents. Javascript is used to execute the individual documents in the dropdown menus. I am trying to get a document sfract.pdf (112.5K)Number of downloads: 72 in the dropdown menu to open at a certain page. I don't want to set this at the document level, because we have several references that open the same document at different pages.
The javascript is:
if (cChoice=="Boating Infrastructure Grant Program")
var otherDoc = app.openDoc
("sfract.pdf", this);
else
How can I get the document to open "sfract.pdf" to a certain page (like page 30)? I have attached the home page/table of contents (toolkit.pdf) and the document I want to open to a certain page (sfract.pdf).
View 1 Replies
View Related
Oct 25, 2010
I was wondering if there exists a script that would do two things:
1) Determine the IP address of the site visitor
2) and, based upon the IP address being either an odd or even number, display a particular version of a webpage. (Odd-numbered IP would show page version A, even numbered IP would show version B)
The reason for desiring the above function is to be able to do a split-test to find out the pulling-power of two slightly different page designs.
View 2 Replies
View Related
Oct 22, 2005
I have PAGE1 with the link to PAGE2 with iframe. (iframe load several
naked html). I want to add directive to the link to point sprcific
content of iframe. to make it clear
link on PAGE1 -> load PAGE2 with iframe -> iframe content is specified
on link = whole PAGE2 with iframe with desired content...
solving problem with creating several different PAGEs2 poining wanted
iframe src is not the case.
View 5 Replies
View Related
Nov 25, 2009
I'm trying to find out how you would pull in specific elements from a HTML file using AJAX.
For example, my AJAX script takes in the URL of the HTML page I want to grab content from (this HTML page is on my server so there are no cross-platform security issues) and it pulls in the HTML document as a string of text rather than a XML/DOM document.
I want to be able to grab a DIV element with a specific ID and pull in all the content from that DIV element.
I know that JavaScript libraries have the ability to do this, but I'm not looking to use a library, I want to use my own Js code. For example this can be done using jQuery's load() method but again I'm looking to implement this with *home-grown* Js code and not have reliance on a Js library for this one aspect of my project.
View 3 Replies
View Related
Jan 24, 2010
I am trying to do is load new content into a form without resetting the form. I have about 10 checkboxes, once 4 are selected I would like to reload a div in the page to insert four corresponding textareas with the same id as the checkboxes. So for example the checkboxes:
Code:
<div id="page_select">
<input type="checkbox" name="option1" id="option1" value="Home" /> Home
<input type="checkbox" name="option2" id="option2" value="About" /> About</div>
There would be about 10 after 4 are selected than four divs with textareas are loaded onto the page - These textareas have the same id in order for the right ones to load. If your wondering why not just hide the textareas and show when then have been selected by the checkboxes, its because they have a wysiwyg editor attach so it would start to load slow after I add say 10-20 different textareas.
Would this work:
Code:
$(document).ready(function() {
$('#reload_1').click(function() {
//var names = [];
var myScripts = new Array(4)
$('#page_select input:checked').each(function() {
names.push(this).attr("id");
});
$('#content_div').load('external_content.php.html # . + '. myScripts[0]);
$('#content_div').load('external_content.php.html # . + '. myScripts[1]);
$('#content_div').load('external_content.php.html # . + '. myScripts[2]);
$('#content_div').load('external_content.php.html # . + '. myScripts[3]);
If I had all the divs and textareas in external_page.php and load only the ones needed.
View 4 Replies
View Related
Jul 20, 2005
I wanted to know how can I check for a specific HTML tag or user defined
TEXT and delete it when the page loads
Whenver the IE loads the page my company add its COMPANY NAME in my
office on any page so what I want to do is to check for my company name
b4 the page loads and remove the company name and then load the page.
I want to do this in JS....
View 4 Replies
View Related
Feb 24, 2011
I would like to be able to access the raw CSS code that has been loaded for the specific page. I'm not looking to change the code (I know how to use jQuery for CSS manipulation etc...) I just want to parse through it and extract some useful information.I considered just loading the stylesheet references in the page, then placing a request to the server for the .css file, but this feels messy even if the browser happens to have the page cached from having just requested it.Has anyone got a clue as to how one would go about this? As always, I think its best if it uses jQuery XD, however, I just really want to get this done
View 2 Replies
View Related
Mar 20, 2011
I would like to use ajax to load a html page and get the content of a specific div. Is it possible to do this?
View 3 Replies
View Related
Nov 8, 2010
The original question was: does anybody know how to load a specific content and not an entire web page when using the jQuery.get below?
$.get('filename.html', function(data) {
$('.class_name').html(data);
});
and was given this code to use/try:
$.get('filename.html', function(data) {
$('.class_name',data).html(); //returns the HTML of .class_name inside of filename.html
});
but it didn't quite work. It loads the entire web page into the defined class name rather than loading a specific content (Look below for further understanding)The filename.html which has content tag names like "[Copyright Year] that goes in the footer position of the site gets dynamically generated.I've created another static page help.html that has pretty much the same content overall except the dynamic content won't get loaded with the content tag (the system doesn't allow static pages to load them). This is what brought me to this solution. So now that I've added a class name to the indicated class that I want to load it pulls all the content and styling of the site rather than just the dynamically generated content of (filename.html) .
<div class="adp_footer">[Copyright Footer]</div> <---- Doesn't get loaded when I used any of the above mention jquery strings,
View 3 Replies
View Related
Jul 21, 2011
I have a (hopefully) simple question.I want to select all buttons on my page except the ones which are inside a specific form.lets say I have following abstract pageconstruction:
<html>
<head />
<body>
[code]....
View 4 Replies
View Related
May 4, 2011
I am currently using:
$("ul.tabs li:first").addClass("active").show();
$(".tab_content:first").show();
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active");
[Code]....
There are 2 options I could use but I don't know how to do it.
1. Using a get parameter to select the tab
2. Using the cookie plugin (not sure how that works)
View 4 Replies
View Related