In the functions that I created below, I constantly gt errors on the variables created on the first lines. Anyone know what that may be?
Thanks:
Code:
<script language="JavaScript">
/* Which browser? */
var IE4 = (document.all);
var NS4 = (document.layers);
/* window to search. */
var win = window;
var n = 0;
function findInPageStudents(str) {
var txt = '';
var i = 0;
var found = '';
if (str == "") return false;
/* Find next occurance of the given string on the page, wrap around to the start of the page if necessary. */
if (NS4) {
/* Look for match starting at the current point.
If not found, rewind back to the first match. */
if (!win.find(str)) while(win.find(str, false, true)) n++; else n++;
/* If not found in either direction, give message. */
if (n == 0) alert("Not found.");
}
if (IE4) {
txt = win.document.body.createTextRange();
/* Find the nth match from the top of the page. */
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart("character", 1); txt.moveEnd("textedit"); }
/* If found, mark it and scroll it into view. */
if (!(found = '')) {
var strStudentMenu = '';
strStudentMenu = 'http://wesleyweb.wesleyseminary.edu/';
strStudentMenu = strStudentMenu + 'WAPROD/WAPROD?type=M&constituency'; strStudentMenu = strStudentMenu + '=WBST&pid=CORE-WBST'; window.location = strStudentMenu;
}
/* Otherwise, start over at the top of the page and find first match. */
else {
if (n > 0) {
n = 0;
findInPageStudents(str);
}
/* Not found anywhere, give message.*/
else alert("Not found.");
}
}
return false;
}
function findInPageFaculty(str) {
var txt = '';
var i = 0;
var found = '';
if (str == "") return false;
/* Find next occurance of the given string on the page, wrap around to the
start of the page if necessary. */
if (NS4) {
/* Look for match starting at the current point.
If not found, rewind back to the first match. */
if (!win.find(str)) while(win.find(str, false, true)) n++; else n++;
/* If not found in either direction, give message. */
if (n == 0) alert("Not found.");
}
if (IE4) {
txt = win.document.body.createTextRange();
/* Find the nth match from the top of the page. */
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart("character", 1); txt.moveEnd("textedit"); }
/* If found, mark it and scroll it into view. */
if (!(found = '')) {
var strStudentMenu;
strStudentMenu = 'http://wesleyweb.wesleyseminary.edu/';
strStudentMenu = strStudentMenu + 'WAPROD/WAPROD?type=M&constituency'; strStudentMenu = strStudentMenu + '=WBFC&pid=CORE-WBFC'; window.location = strStudentMenu;
}
/* Otherwise, start over at the top of the page and find first match. */
else {
if (n > 0) {
n = 0;
findInPageFaculty(str);
}
/* Not found anywhere, give message.*/
else alert("Not found.");
}
}
return false;
}
findInPageStudents('[[[Students]]]');
findInPageFaculty('[[[Faculty]]]');
</script>
Well, I doubt you have created that code, as it appears to have being dug from the bottom of the of the bottom of the Jurassic patterns of the JavaScript (the '90s). These days there are no: 'language="JavaScript", nor NS4, nor IE4... It is a medieval code which I doubt will fit in any modern browser. My God, where did you find it?
Well, I doubt you have created that code, as it appears to have being dug from the bottom of the of the bottom of the Jurassic patterns of the JavaScript (the '90s). These days there are no: 'language="JavaScript", nor NS4, nor IE4... It is a medieval code which I doubt will fit in any modern browser. My God, where did you find it?
In fact, what the code should do?
Basically, what I need the code to do is find some text on the webpage and then, based on the text, redirect the user to a certain site.
Find where? The document might have text within its content, inside form's elements (as string value), and so on...
Within the content of the web document. Not in the elements, etc. but what is visible.
Originally Posted by Kor
What text to find? Compare with what? Where?
A custom string that, based on how the user logs in to the page, the text changes. So, as it stands now I have text that changes on the page to "[[[Students]]]" when a student logs in and "[[[Faculty]]]" when a faculty member logs in.
If everything works correctly the people who log in will barely notice this.
Originally Posted by Kor
Redirect when? What should the user do to redirect the page?
Nothing. The user should log in, the text should appear from the application I am using, and based on the text of the page that appears they should be redirected to the page as defined in the javascript code.
OK. Forget about your code. Put your problem in another way: I need to do that and that, when a user does that and that. Detail. Use common words, if you are not a coder. Be a little more descriptive, please.
OK. Forget about your code. Put your problem in another way: I need to do that and that, when a user does that and that. Detail. Use common words, if you are not a coder. Be a little more descriptive, please.
OK, here you go:
We have a online Student system that students access via the web. The student can search for courses, log into their accounts, and view status messages.
When they log in successfully, they are presented with the same EXACT menu as prescribed before BUT with a link to their prospective section (one set of students get one link, another set of students gets another link).
So, our legacy system does not have the ability to redirect people. Therefore, I would like to create a JavaScript function that redirects people to the appropriate place they need to go based on the link that is sent from the legacy application. I can change the text of the link, so the JavaScript application can find that text.
Bookmarks