Web Analytics Made Easy -
StatCounter document.write function - CodingForum

Announcement

Collapse
No announcement yet.

document.write function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • document.write function

    Hello all,

    Could someone please tell me where in the JSE searchsite script (search.js) I need to modify the code to change the text style in the results page.

    Somewhere I need to place a document.write function, but I cannot work out where in the code it needs to go...

    Thanks anyone who can point the way.

    Here is the code...

    // ---------- script properties ----------

    var include_num = 1;
    var bold = 0;

    // ---------- sites ----------


    var s = new Array();

    s[0] = my links are here so I cut this bit out";

    // ---------- end of script properties and sites ----------


    var cookies = document.cookie;
    var p = cookies.indexOf("d=");

    if (p != -1) {
    var st = p + 2;
    var en = cookies.indexOf(";", st);
    if (en == -1) {
    en = cookies.length;
    }
    var d = cookies.substring(st, en);
    d = unescape(d);
    }
    var od = d;
    var m = 0;
    if (d.charAt(0) == '"' && d.charAt(d.length - 1) == '"') {
    m = 1;
    }

    var r = new Array();
    var co = 0;

    if (m == 0) {
    var woin = new Array();
    var w = d.split(" ");
    for (var a = 0; a < w.length; a++) {
    woin[a] = 0;
    if (w[a].charAt(0) == '-') {
    woin[a] = 1;
    }
    }
    for (var a = 0; a < w.length; a++) {
    w[a] = w[a].replace(/^\-|^\+/gi, "");
    }
    a = 0;
    for (var c = 0; c < s.length; c++) {
    pa = 0;
    nh = 0;
    for (var i = 0; i < woin.length; i++) {
    if (woin[i] == 0) {
    nh++;
    var pat = new RegExp(w[i], "i");
    var rn = s[c].search(pat);
    if (rn >= 0) {
    pa++;
    } else {
    pa = 0;
    }
    }
    if (woin[i] == 1) {
    var pat = new RegExp(w[i], "i");
    var rn = s[c].search(pat);
    if (rn >= 0) {
    pa = 0;
    }
    }
    }
    if (pa == nh) {
    r[a] = s[c];
    a++;
    }
    }
    co = a;
    }

    if (m == 1) {
    d = d.replace(/"/gi, "");
    var a = 0;
    var pat = new RegExp(d, "i");
    for (var c = 0; c < s.length; c++) {
    var rn = s[c].search(pat);
    if (rn >= 0) {
    r[a] = s[c];
    a++;
    }
    }
    co = a;

    }


    function return_query() {
    document.jse_Form.d.value = od;
    }

    function num_jse() {
    document.write(co);
    }

    function out_jse() {
    if (co == 0) {
    document.write('<font face=verdana><font size=2><font color=white><b>Your search did not match any documents.<p>Make sure all keywords are spelt correctly.<br>Try different or more general keywords.</b></font></font></font>');
    return;
    }
    for (var a = 0; a < r.length; a++) {
    var os = r[a].split("^");
    if (bold == 1 && m == 1) {
    var br = "<b>" + d + "</b>";
    os[2] = os[2].replace(pat, br);
    }
    if (include_num == 1) {
    document.write(a + 1, '. <font face=verdana><font size=2><a href="', os[1], '">', os[0], '</a><br></font></font>', os[2], '<p>');
    } else {
    document.write('<a href="', os[1], '">', os[0], '</a><br>', os[2], '<p>');
    }
    }

    }

  • #2
    if you look at the code it has font tags in the document.write statements. That is where you would change it.

    It is in 2 places.

    1-Saying there are no results
    2- where it returns the results.

    I personally would change the tags to CSS divs or paragraphs and get rid of the outdated tags and you would have more control.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

    Comment


    • #3
      Thanks Eric, and yes, I can see the document.write tags, I put them in myself...

      What I cannot seem to see is where the script generates the paragraph description of the searched item.

      e.g.

      Facing the Dragon (documentary title searched and link to specific page)

      A 52 minute documentary on blah blah (this is the synopsis of the film under the hyperlinked title)

      This is the bit I can't work out how it's generated in the code as it does not seem to have an obvious write function.

      But thanks anyway for the tip about CSS. I'll certainly implement that.

      David.

      Comment

      Working...
      X