IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Modifier la couleur d'un lien depuis une frame


Sujet :

JavaScript

  1. #1
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut Modifier la couleur d'un lien depuis une frame
    Salut,

    Voilà mon problème :
    J'ai une page avec 2 frames :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
            <frame name="contents" target="main" src="sommaire.htm" scrolling="auto" resize="no">
        <frame name="main" src="principal.htm" scrolling="auto" target="_self">
    J'aimerais qu'en cliquant sur un lien de ma page 'Principal.htm', l'un des liens de ma page 'Sommaire.htm' change de couleur.

    Si quelqu'un est prêt à m'aider, voilà mes pages HTML :
    La page de frame :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
      <frameset name="tocbody" framespacing="5" cols="248,*">
        <noframes>
        <p>This page uses frames, but your browser doesn't support them.</p>
        </noframes>
        <frame name="contents" target="main" src="sommaire.htm" scrolling="auto" resize="no">
        <frame name="main" src="principal.htm" scrolling="auto" target="_self">
      </frameset>
    </frameset>
    La page Sommaire (à gauche)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <html>
    <head>
    <title>Sommaire</title>
    <base target="main">
    </head>
    <body>
    <div>Sommaire</div>
    </body>
    </html>
    La page Principal (à droite) suivi de la page atteinte en cliquant sur le lien
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <html>
    <head>
    <base target="_self">
    </head>
    <body>
    <p>Principal</p>
    <p><a onclick=this.style.color='red' href="lien_suivi.htm">lien</a></p>
    </body>
    </html>
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <html>
    <head>
    <title>Lien suivi</title>
    </head>
    <body>
    <p>Lien suivi</p>
    </body>
    </html>
    J'ai essayé en mettant un id sur mon div mais je n'arrive pas à l'appeler de ma page principale. Et pas non plus de succès en essayant quelque chose comme ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    onclick=parent.contents.style.color='red'
    Si quelqu'un est prêt à me donner un coup de main (au moins pour commencer...) ce serait super !

    A+

  2. #2
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    onclick=parent.contents.style.color='red'
    contents est un objet de type window, donc il ne possède pas de propriété style...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    onclick=parent.contents.document.getElementById('id_de_ta_div').style.color='red'
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  3. #3
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    Wouhou !

    Ca marche nikel ! Un grand merci, je peux continuer mon code à présent.

    A+

  4. #4
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    J'ai adapté mon code à la réponse mais j'ai un problème de navigateur maintenant :s
    Ca marche dans FF mais pas dans IE.

    Pour reprendre depuis le début, ma page principal est en fait un moteur de recherche. Les réponses sont affichées dynamiquement dans cette même page.
    Je voulais que lorsque je clique sur une réponse, le lien correspond au div du sommaire soit highlighter.
    Donc dans FF, nikel, dans IE rien du tout, même pas de message d'erreur.
    Faut-il recharger la page ? (je n'y crois pas trop mes tests n'ont pas été concluants, à moins d'une erreur...)

    Je mets mon code à disposition au cas où...

    Page principale Principal.htm:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <html>
    <head>
    <script language="Javascript" src="db.js"></script>
    <script language="Javascript" src="search.js"></script>
    </head>
    <body>
    <!-- saved from url=(0013)about:internet -->
    <script language="Javascript">
    initSearch();
    </script>	
    </body>
    </html>
    Page de sommaire (à gauche) : Sommaire.htm
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <html>
    <head>
    <title>Sommaire</title>
    <base target="main">
    </head>
    <body>
    <span id="1">Sommaire</span>
    </body>
    </html>
    Page de frame : Index.htm
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
      <frameset name="tocbody" framespacing="5" cols="248,*">
        <noframes>
        <p>This page uses frames, but your browser doesn't support them.</p>
        </noframes>
        <frame name="contents" target="main" src="sommaire.htm" scrolling="auto" resize="no">
        <frame name="main" src="principal.htm" scrolling="auto" target="_self">
      </frameset>
    </frameset>
    Base de données JS: db.js
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    /* Search - Database file */
    var records_count=0; 
    v1 = new Array(records_count);
    v2 = new Array(records_count);
    v3 = new Array(records_count);
    var a=0;
    function fresh(url1) {
    parent.main.location.href= url1;
    }
     
     
    ////////////////////////////////////////////////////////////////
    a +=1
    v1[a]="<a onclick=parent.contents.document.getElementById('1').style.background='blue' href=javascript:fresh('Lien_suivi.htm')>Lien suivi</a>"
    v2[a]="lien suivi"
    v3[a]="" 
    ////////////////////////////////////////////////////////////////
    records_count = a;
    Fonction de recherche JS (je sais elle est longue et je ne comprend que la moitié des choses mais elle fonctionne... jusqu'à maintenant) search.js
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    /* Based on Search version5.0 */
    // Le nom du fichier
    var searchname = 'principal.htm';
    // Le nom et l'adresse du boutonvar usebannercode = true;
    var ButtonCode = "<img src='../DLIP/searchbutton.gif' border=0>";
    var usebannercode = true;
     
    // Création du corps de la page HTML
    function templateBody()
    {
    ////// modifications possibles ///////
      document.write('<html><head><title>Rechercher</title></head><body bgcolor="#ffffff" text="#000000" link="#000099" vlink="#996699" alink="#996699"><table width=0><tr><td width=0><font color="#000000"><font face="Arial" size="14"><font face=Arial, Verdana size=6><b>Rechercher</font></font></center></td><td width=0><div align=right></div></td></tr></table><center><table border=0 width=0><tr><td>');
    }
     
    // Fin de la page
    function templateEnd()
    {
      document.write('</td></tr></table></font></center></body></html>');
    }
    ////// fin de  modifications ///////
    function bannerCode()
    {
     
    }
    //-----------------------------------------------------------------------------------------------
    var finds =0;
    var sites =0;
    var version = "v5.0"
    var andresult = false;
    var SortResults = true;
    var display_start = 1;	
    var displast = 20;
     
    function searchAll(keyword)
    {
    	var timeA=new Date();
    	var nw=1;
    	finds=0;
    	sites=0;
     
    	var x = parseIt(keyword);
    	if(x == -1)	return;
    	total_keywords=x;
     
    	document.open();
    	document.clear();
    	document.write('<link rel="stylesheet" href="search.css">');
    	AddBody();
     
    	if (keyword.length>50) keyword=keyword.substring(0,60)+"...";
     
    	results=new makeArray(records_count,1);
    	order=new makeArray(records_count,1);
    	for (q=1; q<=results.length; q++)
      {
      	results[q]=0;
    	  order[q]=q;
    	}
    	data=new makeRecordLinks(records_count);
    	while(keywords[nw].length > 1)
    	{
    	  search(data,keywords[nw]);
    	  nw++;
    	} 
     
    	if (andresult)
    	{
    	  for (a=1; a<=results.length; a+=1)
    	  {
    	    if (results[a]>0)
    	    {
          	if (results[a]<=(total_keywords-1)*2)
    	      {
    	        results[a]=0;
    	        sites-=1;
    	      }
    	    }
    	  }
    	}
     
    	var temp =0;
     
    	if ((SortResults==true)&&(keywords!='[all]'))
    	{
        for (a=results.length; a>=2; a-=1)
    	  {
        	for (b=1; b<a; b+=1)
    	    {
          	if (results[order[a]]>results[order[b]])
          	{
            	temp=order[b];
    	        order[b]=order[a];
    	        order[a]=temp;
    	      }
    	    }
    	  }
    	} 
      else
      {
      	b=0;
      	for (a=results.length; a>=2; a-=1)
      	{
        	if (results[a]>0)
    	    {
    	      order[b]=a;
    	      b++
    	    }
    	  }
    	}
     
    	// Now we build the output page
    	displast=display_start+20;
    	if (displast>sites) displast=sites+1;
    	var timeB=new Date();
    ////// modifications possibles ///////
    	document.write("<center><h3>R&eacute;sultats : <b>"+display_start+"-"+(displast-1)+"</b> de <b>"+sites+"</b> pour 		<b>"+keyword+"</b>. Dur&eacute;e de la recherche : <b>"+((timeB-timeA)/1000)+"</b> secondes.</h3></center>");
    	if (finds==0)
    	{
      	document.write("<h3><font color=green>Pas de r&eacute;sultats pour  <b>''"+keyword+"''</b>.</font></h3>"+
      	"<p>Votre recherche sur - <b>"+keyword+"</b> - n'a trouv&eacute; aucun document correspondant dans la base de 		donn&eacute;es.</p>"+
    	  "<ul><LI>Assurez-vous que les mots sont bien orthographi&eacute;s.</li>"+
    	  "<LI>Essayez avec moins de mots.</li>"+
    	  "<LI>Essayez d\'autres mots-clés.</li></ul></span>"+
    	  "</p>");
    ////// fin de  modifications ///////			
    	  DisplaySearch();
    	  document.close();
    	  return
      }
     
    	q2=display_start;
    	q3=displast;
    	for (q=display_start; q<q3;)
    	{
    	  if (results[order[q]]>0)
    	  {
    	    document.write("<span class='xtitle'>"+data[order[q]].v1+"</span><br>");
    	    x1=v1[order[q]].indexOf('http://')+7;
    	    if (x1==6) x1=v1[order[q]].indexOf('href=')+5;
    	    x2=v1[order[q]].indexOf('>');
    	    if (x1>0 && x2>0)
    	    {
    	      tmp=v1[order[q]].substring(x1,x2);
          	x2=tmp.indexOf(' ');
    	      if (x2>0) tmp=tmp.substring(0,x2);
    	      if (tmp.substring(0,1)=="'") tmp=tmp.substring(1,tmp.length-1);
    	      if (tmp.substring(0,1)=='"') tmp=tmp.substring(1,tmp.length-1);
          	document.write("<table border=0 width=500><tr><td><span class='xresult'>"+v3[order[q]]+"</span></td></tr></table><span class='xlocation'></span><br><br>");
    //document.write("<table border=0 width=500><tr><td><span class='xresult'>"+v3[order[q]]+"</span><br><br>");
    	    }
    	    q2++;
       	}
    	  q+=1;
    	}
     
    	if (finds>20)
    	{
    	  document.write("<BR>");
    	  pages=Math.round(finds/20);
    	  if (finds%20<6)	pages++;
     
    	// Create the parameter string
      	paramstring=searchname+"?keywords="+keyword+"&and="+andresult+"&sort="+SortResults;
    	  document.write("<center><span class='xsmall'>");
    ////// modifications possibles ///////
    	  if (display_start>1) document.write("<a href='"+paramstring+"&disp="+(display_start-20)+"'>page pr&eacute;c&eacute;dente</a>");
    	  document.write("&nbsp;&nbsp;&nbsp;");
    	  for (i=1; i<=pages;)
        {
    	    if ((((i-1)*20)+1)<=sites)
          {
    	      document.write("<a href='"+paramstring+"&disp="+(((i-1)*20)+1)+"'>"+i+"</a>&nbsp&nbsp ");
    	    }
    	    i++;
    	  }
    	  document.write("&nbsp;&nbsp;&nbsp;");
    	  if (displast<=sites) document.write("<a href='"+paramstring+"&disp="+(displast)+"'>page suivante</a>");
    	  document.write("</span></center>");
    	}
    ////// fin de  modifications ///////			
    	DisplaySearch();
    	document.close();
    }
     
    function Cat()
    {
    	document.open();
    	document.clear();
    	AddBody();
    	DisplaySearch();
    	document.close();
    }
     
     
    function makeArray(n,vartype) 
    {
    	this.length = n;
    	for (var k = 1; k <= n; k++) 
      {
    	  if (vartype==0)
        {
    	    this[k] = "";
    	  }
        else
        {
    	    this[k] = 0;
    	  }
    	}
    	return this;
    }               
     
    function stripInput(key)
    {
    	while(key.substring(0,1) == ","  || key.substring(0,1) == " " ) key = key.substring(1,key.length);
    	while(key.substring(key.length-1,key.length) == "," || key.substring(key.length-1,key.length) == " ") key = 			key.substring(0,key.length-1);
    	return key;
    }
     
    function parseIt(key) 
    {
    	key = stripInput(key)+" ";
    	var y = 1;
    	while(key.indexOf(" ") > 0)
    	{
      	if (key.substring(0,1)=='"')
    	  {
    	    var pos=key.indexOf('"',2);
    	    keywords[y]=key.substring(1,pos);
    	    keywords[y]=stripInput(keywords[y]);
    	    y++;
    	    key=key.substring(pos+1,key.length);
    	  }
        else
        {
    	    var pos=key.indexOf(' AND ');
    	    if ((pos>0) && (key.indexOf(' ')>=pos))
    	    {
    	      pos=key.indexOf(' ',pos+5);
    	      keywords[y]=key.substring(0,pos);
    	      keywords[y]=stripInput(keywords[y]);
    	      y++;
    	      key=key.substring(pos+1,key.length);
    	      if (key.substring(0,4)=='AND ')
    	      {
    	        pos=keywords[y-1].indexOf(' ')+5;
    	        key=keywords[y-1].substring(pos,keywords[y-1].length)+' '+key;
    	      }
    	    }
          else
          {
    	      var pos=key.indexOf(' OR ');
    	      if ((pos>0) && (key.indexOf(' ')>=pos))
    	      {
    	        pos=key.indexOf(' ');
    	        keywords[y]=key.substring(0,pos);
    	        keywords[y]=stripInput(keywords[y]);
    	        if (keywords[y]!=keywords[y-1])	y++;
    	        key=key.substring(pos+1,key.length);
    	        pos=key.indexOf('OR ');
    	        key=key.substring(pos+3,key.length);
    	        pos=key.indexOf(' ');
    	        keywords[y]=key.substring(0,pos);
    	        keywords[y]=stripInput(keywords[y]);
    	        y++;
    	        key=key.substring(pos+1,key.length);
    	        if (key.substring(0,3)=='OR ') key=keywords[y-1]+' '+key;
    	      }
            else
            {
    	        var pos = key.indexOf(" ");
    	        keywords[y]=key.substring(0,pos);
    	        keywords[y] = stripInput(keywords[y]); 
    	        y++;
    	        if(y > 50) return -1
    	          key=key.substring(pos+1,key.length);
    	      }
    	    }
    	  }
    	}
    	return y-1;
    }
     
    var keywords = new makeArray(50,0);
    var results;
    var foundword;
    var data;
    var order;
    var total_keywords;
     
    function dataEntry ()
    {
    	this.v1="";
    	this.v2="";
    	return this;
    }
     
    function makeRecordLinks(size)
    {
    	this.length = size;
    	for (var r=1; r<= size; r++) 
    	{
        this[r] = new dataEntry();
    	  this[r].v1 = v1[r];
    	  this[r].v2 = v2[r]; 
    	}
    	return this;
    }
     
     
    // Page HTML telle que vue à l'écran
    function AddBody()
    {
    	var keytext='"'+searchname+'?keywords="+';
    	var andtext='"&and="+';
    	document.write('<script>function doSearch(){'+
    	'searchwords=document.searchform.searchwords.value; '+
    	'while (searchwords.indexOf(" ")>-1){ pos=searchwords.indexOf(" ");'+
    	'searchwords=searchwords.substring(0,pos)+"+"+searchwords.substring(pos+1); }'+
    	'document.location='+keytext+' searchwords+'+andtext+'"0"}'+
    	'<'+'/'+'script>'
    	);
     
    	templateBody();
    ////// modifications possibles ///////
    	document.write('<html><p><br></p><table width=0><tr><td width=0><font color="#000000"><font face="Arial" size="10"><font face=Arial, Verdana size=2>Taper le ou les mots correspondant(s) à la recherche.</font></font></td><td width=0></td></tr></table><table border=0 width=0><tr><td>');
    	document.write("<br><form name='searchform' method='post' action='javascript:doSearch()'><table border='0' width='100%'><tr><td 	align='center'><font face='Arial' size='6'><input name='searchwords' type='text' size='65'>&nbsp;&nbsp;<a 	href='javascript:doSearch()'>"+ButtonCode+"</a></font></td></tr></table></form>");
    	document.write('<html><p><br></p><table width=0><tr><td width=0><font color="#000000"><font face="Arial" size="10"><font face=Arial, Verdana size=2>Lorsque plusieurs mots clés sont saisis, la recherche s\'effectue dans les pages où au moins l\'un des mots apparaît.</font></font></td><td width=0></td></tr></table><table border=0 width=0><tr><td>');
    	document.write('<html><font face="Arial" size="10"><font face=Arial, Verdana size=2>Saisir AND entre chaque mots clés (exemple : mot1 AND mot2), afin de rechercher les pages dans lesquelles tous les mots clés saisis apparaissent.</font></font></td><td width=0></td></tr></table><table border=0 width=0><tr><td>');
    //  document.write(navigator.appName);
      if (navigator.appName!="Netscape")
        document.searchform.searchwords.focus();
    ////// fin de  modifications ///////			
    	if (usebannercode) bannerCode();
    }
     
     
    // Inscription Bas de page + fin de code HTML pour la page
    function DisplaySearch()
    {
    ////// modifications possibles ///////
    //document.write("<center><hr size=1></center>")
    //	document.write("<Font size=-1><center>R&eacute;alis&eacute; avec <a href=http://www.twicefun.com/just4fun>Search 	"+version+"</a>  - Free Javascript SearchEngine</center></font>");
    ////// fin de  modifications ///////		
    	templateEnd();
    }
     
    function search(records, keyword)
    {
    	var hit=0;
    	var addcomplete=0;
     
    	for (q=1; q<=records.length; q++) 
      {
    	  addcomplete=0;
    	  search_parm=records[q].v2.toLowerCase()+" "+v3[q].toLowerCase();
     
    	  if (keyword.indexOf(' AND ')>0)
    	  {
    	    firstword=keyword.substring(0,keyword.indexOf(' '));
    	    lastword=keyword.substring(keyword.indexOf(' AND ')+5,keyword.length);
    	    if ((search_parm.indexOf(" "+firstword+" ") != -1) && (search_parm.indexOf(" "+lastword+" ")!= -1 ))
    	    {
    	      hit++;
    	      finds++;
    	      if(hit < 2)
    	      { 
    	        if (results[q]==0) sites++;
    	          results[q] +=2;
    	      } 
    	    }
    	  }
        else
        {
    	    keyword=keyword.toLowerCase();
    	    if ((search_parm.indexOf(" "+keyword+" ") != -1) ||(keyword=="[all]"))
    	    {
    	      hit++;
    	      finds++;
    	      if(hit<2)
    	      { 
    	        if (results[q]==0) sites++;
    	        results[q]+=2;
    	      } 
    	    }
          else
          {
    	// check for a half hit (ie. search:share find:SHAREware)
          	if (search_parm.indexOf(keyword) != -1)
    	      {
    	        hit++;
    	        finds++;
    	        if(hit < 2)
    	        {
    	          if (results[q]==0) sites++;
    	          results[q]+=1;
    	          x=search_parm.indexOf(keyword)+keyword.length;
    	          pos=search_parm.substring(1,x-keyword.length);
    	          while (pos.indexOf(" ")!=-1)
    	          {
    	            y=pos.indexOf(" ");
    	            pos=pos.substring(y+1,pos.length);
    	          }
    	          if (pos.length<=2) addcomplete++;
     
    	          pos=search_parm.substring(x,search_parm.length);
    	          fullresult=search_parm.substring(x,x+pos.indexOf(" "));
     
    	          if (fullresult.length<=2) addcomplete++;
    	          if (addcomplete>1) results[q]+=1;
    	        }
    	      }
    	     }
    	    }
    	    hit=0;
      } 
    }                                       
     
    var searchwords = '';
    var newload = true;
     
    function countParams(text)
    {
    	pos=-1;
    	tmp = "";
    	if (text=='') return 0;
    	text=text+'&';
    	i=0;
    	while (text.length>0)
    	{
      	pos=text.indexOf('&',0);
    	  tmp=text.substring(pos+1);
      	text=tmp;
    	  i++;
    	}
    	return i;
    }	
     
    function getCommand(text,val)
    {
    	pos=-2;
    	tmp = "";
    	text=text+'&';
    	for (i=0; i<=val;)
    	{
      	pos2=pos+2;
    	  pos=text.indexOf('&',pos2);
      	tmp=text.substring(pos,pos2-1);
    	  i++;
    	}
    	text=tmp;
    	pos=text.indexOf('=',0);
    	if (pos!=-1) tmp=text.substring(pos,0);
    	tmp=tmp.toLowerCase();
    	return tmp;
    }
     
    function getValues(text,val)
    {
    	pos=-2;
    	tmp = "";
    	text=text+'&';
    	for (i=0; i<=val;)
    	{
      	pos2=pos+2;
    	  pos=text.indexOf('&',pos2);
      	tmp=text.substring(pos,pos2-1);
    	  i++;
    	}
    	text=tmp;
    	pos2=text.indexOf('=',0)+1;
    	if (pos2!=-1)
    	{
    	  tmp=text.substring(pos2);
    	} 
      else 
      { 
    	  tmp='' 
    	}
     
    	pos=-2;
    	text=tmp;	
    	if (text.indexOf('%20')>0)
    	{
    	  pos=text.indexOf('%20',0);
      	tmp=text.substring(0,pos2-4)+' '+text.substring(pos2-1,text.length);
    	  text=tmp;
    	}
    	return tmp;
    }		
     
    function initSearch()
    {
    	if (searchwords!='')
    	{
      	searchAll(searchwords);
    	}
      else 
      {
      	if (newload) Cat();
    	}
    }
     
    function doParamStuff(findw)
    {
    	Myparams=countParams(findw);
    	if (Myparams>0)
    	{
      	for (cnt=0; cnt<Myparams;)
    	  {
        	tempw=getCommand(findw,cnt);
        	tempv=getValues(findw,cnt);
        	if (tempw=='keywords')
        	{
          	searchwords=getValues(findw,cnt);
          	origsearchwords=searchwords;
          	while (searchwords.indexOf('+')>-1)
          	{
            	pos=searchwords.indexOf('+');
            	searchwords=searchwords.substring(0,pos)+' '+searchwords.substring(pos+1);
          	}
    	    }
        	if (tempw=='sort')
        	{
          	if ((tempv=='0')||(tempv=='false'))
          	{
            	SortResults=false;
          	}
            else
            {
            	SortResults=true;
    	      }
    	    }
     
      	  if (tempw=='and')
        	{
          	if ((tempv=='1')||(tempv=='true'))
          	{
            	andresult=true;
    	      }
            else
            {
            	andresult=false;
    	      }
    	    }
        	if (tempw=='disp') display_start=parseInt(tempv);
    	    cnt +=1;
    	  }
    	}
    }
     
    findw=document.location.search;
    findw="&"+findw.substring(1,findw.length);
     
    while (findw.indexOf('%20')>0)
    {
    	pos2=findw.indexOf('%20',0);
    	tmp=findw.substring(0,pos2)+' '+findw.substring(pos2+3,findw.length);
    	findw=tmp;
    }
    doParamStuff(findw);
    Si quelqu'un a une idée !

    [EDIT]
    J'ai trouvé cette fonction :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    if(!document.getElementById){
      if(document.all){
        document.getElementById=function(){
    if(typeof document.all[arguments[0]]!="undefined"){return document.all[arguments[0]]}else{return null}
        }
      }else if(document.layers){
        document.getElementById=function(){
    if(typeof document[arguments[0]]!="undefined"){return document[arguments[0]]}else{return null}
        }
      }
    }
    qui permettrait de rendre multi navigateur le getElementById mais je n'arrive pas à la faire fonctionner.
    Personne n'a une idée ?

    A+

  5. #5
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    Je n'avance plus !
    J'ai essayé de générer la page de réponses en mettant la fonction trouvée :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    ////// modifications possibles ///////
    	document.write('<html><head>');
    	document.write("<SCRIPT language='javascript'>");
    	document.write('if(!document.getElementById){');
    	document.write('  if(document.all){');
    	document.write('    document.getElementById=function(){');
    	document.write('if(typeof document.all[arguments[0]]!="undefined"){return document.all[arguments[0]]}else{return null}');
    	document.write('    }');
    	document.write('  }else if(document.layers){');
    	document.write('    document.getElementById=function(){');
    	document.write('if(typeof document[arguments[0]]!="undefined"){return document[arguments[0]]}else{return null}');
    	document.write('    }');
    	document.write('  }');
    	document.write('}</SCRIPT>');
    	document.write('</head>');
    	document.write('<p><br></p><table width=0><tr><td width=0><font color="#000000"><font face="Arial" size="10"><font face=Arial, Verdana size=2>Taper le ou les mots correspondant(s) à la recherche.</font></font></td><td width=0></td></tr></table><table border=0 width=0><tr><td>');
    	document.write("<br><form name='searchform' method='post' action='javascript:doSearch()'><table border='0' width='100%'><tr><td 	align='center'><font face='Arial' size='6'><input name='searchwords' type='text' size='65'>&nbsp;&nbsp;<a 	href='javascript:doSearch()'>"+ButtonCode+"</a></font></td></tr></table></form>");
    	document.write('<html><p><br></p><table width=0><tr><td width=0><font color="#000000"><font face="Arial" size="10"><font face=Arial, Verdana size=2>Lorsque plusieurs mots clés sont saisis, la recherche s\'effectue dans les pages où au moins l\'un des mots apparaît.</font></font></td><td width=0></td></tr></table><table border=0 width=0><tr><td>');
    	document.write('<html><font face="Arial" size="10"><font face=Arial, Verdana size=2>Sacisir AND entre chaque mots clés (exemple : mot1 AND mot2), afin de rechercher les pages dans lesquelles tous les mots clés saisis apparaissent.</font></font></td><td width=0></td></tr></table><table border=0 width=0><tr><td>');
     //document.write(navigator.appName);
      if (navigator.appName!="Netscape")
        document.searchform.searchwords.focus();
    ////// fin de  modifications ///////
    Mais rien n'y fait... IE fait encore de la résistance...
    Je comprend que la fonction search.js est super longue et que ça doit pas motiver à lire mon message mais bon au cas où il y ait une âme charitable !

  6. #6
    Membre chevronné
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    397
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 397
    Par défaut
    document.getElementById('id') n'est-il pas déjà cross-browser ?

  7. #7
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    Ben c'est ce qu'il me semblait mais j'ai trouvé cette fonction en cherchant sur le net.
    Dans tous les cas ça peut pas faire de mal...
    Et pour tout avouer je desespère un peu donc j'essaie un peu tout ce que je trouve...

  8. #8
    Membre chevronné
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    397
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 397
    Par défaut
    Commences par écrire :

    dans ta fonction fresh() pour voir si elle est bien appelée.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    v1[a]="<a onclick=\"parent.contents.document.getElementById('1').style.background='blue'\" href=\"javascript:fresh('Lien_suivi.htm')\">Lien suivi</a>"
    Je dis ça, mais je n'ai même pas compris exactement ce qui ne marchait pas sur IE...

  9. #9
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    Alors j'ai bien le message d'alert sur Fresh donc ça ça marche bien.
    J'ai remplacé mon code par le tien dans v1 mais pas mieux.

    Alors ce qui ne marche pas :
    si tu prend les pages que j'ai posté et que tu les mets toutes dans un même dossier, tu recherches "lien" dans le moteur.

    Le lien "Lien suivi" s'affiche, tu cliques dessus dans IE, la page Lien_suivi.htm s'affiche (si tu l'a créé) dans la frame main, et sommaire reste affiché tel quel dans la frame contents.

    Si tu es par contre dans FF, en faisant la même recherche, quand tu cliques sur le lien, Sommaire s'affiche highlighter en bleu.

    Ca marche chez toi ?

  10. #10
    Membre chevronné
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    397
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 397
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    v1[a]="<a onclick=\"alert(parent.contents.document.getElementById('1').style.background)\" href=\"javascript:fresh('Lien_suivi.htm')\">Lien suivi</a>"
    Ceci te permettra de voir si IE comprend ce paramètre...

    Un backgroundColor serait peut-être plus efficace...qu'un background.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    v1[a]="<a onclick=\"parent.contents.document.getElementById('1').style.backgroundColor = 'blue'\" href=\"javascript:fresh('Lien_suivi.htm')\">Lien suivi</a>"

  11. #11
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    Alors effectivement je n'ai pas de message d'alerte quand je suis sous IE !
    Je l'ai bien sous FF.

    Arf, ça peut venir de quoi ?
    Il faut que je mette un truc du style 'if IE / if FF' ?

    Par contre, background ou backgroundcolor, même combat. J'ai laissé le tien dans le doute.

  12. #12
    Membre chevronné
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    397
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 397
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    v1[a]="<a onclick=\"if(parent.contents){parent.contents.document.getElementById('1').style.backgroundColor = 'blue'}else{top.contents.document.getElementById('1').style.backgroundColor = 'blue'}\" href=\"javascript:fresh('Lien_suivi.htm')\">Lien suivi</a>"
    Quelque chose comme ceci peut-être?

    Comme cela si c'est parent.contents que IE ne comprends pas, il ira sur le else ou on utilise top.

  13. #13
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    Impec ça a l'air de marcher !
    J'ai juste remplacé "top" par "_top" dans ton code pour qu'il reconnaisse bien le cadre.

    Merci beaucoup !

  14. #14
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par défaut
    Citation Envoyé par emmeline.a Voir le message
    J'ai juste remplacé "top" par "_top" dans ton code pour qu'il reconnaisse bien le cadre.
    Attention, _top correspond à la valeur d'un attribut HTML target. En JavaScript, c'est bien top qu'il faut utiliser pour cibler la fenêtre la plus haute hiérarchiquement, et le contenu d'un attribut onclick correspond à du code JavaScript, pas HTML
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  15. #15
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    Ok ca marche, je note "ne plus prendre d'initiative" ^^

    Bon alors en fait j'ai bien peur que le problème ne soit pas là finalement.
    Dans IE, mon lien n'est pas surligné à chaque fois.
    Des fois, tout se passe bien le lien est bien highlighter en bleu, puis ensuite je réouvre ma page, fais la même manip', et le lien reste inchangé...
    Mes recherches restent sans succès.

    J'ai bien essayé de virer l'historique mais ça n'a pas l'air d'être ça.

    Quelqu'un a déjà eu ce problème ?

  16. #16
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    Salut,

    J'ai toujours ce problème d'highlight qui marche sous FF mais pas sous IE ni Chrome.
    J'ai un peu avancé mais vu le nombre d'heure passé ça n'a pas vraiment donné grand chose...
    Voilà ma conclusion, la page Sommaire.htm n'est pas chargée correctement ou tout du moins au bon moment. En effet, mon id contenu dans le sommaire n'a pas l'air reconnu :
    Du coup j'obtiens les erreurs suivantes :
    Accès refusé dans IE et valeur de getElementById('1')=null dans IE
    Cannot call method 'getElementById' of undefined dans Chrome
    (getElementById('1')=null aussi dans FF, même si le highlight fonctionne...)

    Seulement voilà, comment faire pour que l'ID soit bien interprété ?

    Bon alors première question, est ce que je poste une nouvelle discussion vu que ce n'est plus exactement le même sujet qu'au début ?
    Et si ça passe, voilà mes fonctions (si besoin d'un exemple en html, mes pages sont plus bas dans la message) :

    db.js :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    /* Search - Database file */
     
    var records_count=0; 
    v1 = new Array(records_count);
    v2 = new Array(records_count);
    v3 = new Array(records_count);
    var a=0;
     
    function fresh(url1) {
    parent.main.location.href= url1;
    alert(url1);
     
    }
     
    /* Essai avec cette fonction non concluant
    function loadPage(url){
    parent.contents.location.href=url;
    }
    */
     
    ////////////////////////////////////////////////////////////////
    a +=1
    v1[a]="<a href=\"javascript:fresh('Lien_suivi.htm')\" onclick=\"{alert(getElementById('1'));top.contents.document.getElementById('1').style.backgroundColor = 'blue'}\">Lien suivi</a>"
    v2[a]="lien suivi"
    v3[a]=""
    ////////////////////////////////////////////////////////////////
     
    records_count = a;
    Search.JS
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    /* Based on Search version5.0 */
    // Le nom du fichier
    var searchname = 'principal.htm';
    // Le nom et l'adresse du boutonvar usebannercode = true;
    var ButtonCode = "<img src='../DLIP/searchbutton.gif' border=0>";
    var usebannercode = true;
     
    // Création du corps de la page HTML
    function templateBody()
    {
    ////// modifications possibles ///////
      //document.write('<html><head><title>Rechercher</title></head><body bgcolor="#ffffff" text="#000000" link="#000099" vlink="#996699" alink="#996699"><table width=0><tr><td width=0><font color="#000000"><font face="Arial" size="14"><font face=Arial, Verdana size=6><b>Rechercher</font></font></center></td><td width=0><div align=right></div></td></tr></table><center><table border=0 width=0><tr><td>');
    }
     
    // Fin de la page
    function templateEnd()
    {
      //document.write('</td></tr></table></font></center></body></html>');
    }
    ////// fin de  modifications ///////
    function bannerCode()
    {
     
    }
    //-----------------------------------------------------------------------------------------------
    var finds =0;
    var sites =0;
    var version = "v5.0"
    var andresult = false;
    var SortResults = true;
    var display_start = 1;	
    var displast = 20;
     
     
    function searchAll(keyword)
    {
    	var timeA=new Date();
    	var nw=1;
    	finds=0;
    	sites=0;
     
    	var x = parseIt(keyword);
    	if(x == -1)	return;
    	total_keywords=x;
     
    	document.open();
    	document.clear();
    	document.write('<link rel="stylesheet" href="search.css">');
    	AddBody();
     
    	if (keyword.length>50) keyword=keyword.substring(0,60)+"...";
     
    	results=new makeArray(records_count,1);
    	order=new makeArray(records_count,1);
    	for (q=1; q<=results.length; q++)
      {
      	results[q]=0;
    	  order[q]=q;
    	}
    	data=new makeRecordLinks(records_count);
    	while(keywords[nw].length > 1)
    	{
    	  search(data,keywords[nw]);
    	  nw++;
    	} 
     
    	if (andresult)
    	{
    	  for (a=1; a<=results.length; a+=1)
    	  {
    	    if (results[a]>0)
    	    {
          	if (results[a]<=(total_keywords-1)*2)
    	      {
    	        results[a]=0;
    	        sites-=1;
    	      }
    	    }
    	  }
    	}
     
    	var temp =0;
     
    	if ((SortResults==true)&&(keywords!='[all]'))
    	{
        for (a=results.length; a>=2; a-=1)
    	  {
        	for (b=1; b<a; b+=1)
    	    {
          	if (results[order[a]]>results[order[b]])
          	{
            	temp=order[b];
    	        order[b]=order[a];
    	        order[a]=temp;
    	      }
    	    }
    	  }
    	} 
      else
      {
      	b=0;
      	for (a=results.length; a>=2; a-=1)
      	{
        	if (results[a]>0)
    	    {
    	      order[b]=a;
    	      b++
    	    }
    	  }
    	}
     
    	// Now we build the output page
    	displast=display_start+20;
    	if (displast>sites) displast=sites+1;
    	var timeB=new Date();
    ////// modifications possibles ///////
    	document.write("<center><h3>R&eacute;sultats : <b>"+display_start+"-"+(displast-1)+"</b> de <b>"+sites+"</b> pour 		<b>"+keyword+"</b>. Dur&eacute;e de la recherche : <b>"+((timeB-timeA)/1000)+"</b> secondes.</h3></center>");
    	if (finds==0)
    	{
      	document.write("<h3><font color=green>Pas de r&eacute;sultats pour  <b>''"+keyword+"''</b>.</font></h3>"+
      	"<p>Votre recherche sur - <b>"+keyword+"</b> - n'a trouv&eacute; aucun document correspondant dans la base de 		donn&eacute;es.</p>"+
    	  "<ul><LI>Assurez-vous que les mots sont bien orthographi&eacute;s.</li>"+
    	  "<LI>Essayez avec moins de mots.</li>"+
    	  "<LI>Essayez d\'autres mots-clés.</li></ul></span>"+
    	  "</p>");
    ////// fin de  modifications ///////			
    	  DisplaySearch();
    	  document.close();
    	  return
      }
     
    	q2=display_start;
    	q3=displast;
    	for (q=display_start; q<q3;)
    	{
    	  if (results[order[q]]>0)
    	  {
    	    document.write("<span class='xtitle'>"+data[order[q]].v1+"</span><br>");
    	    x1=v1[order[q]].indexOf('http://')+7;
    	    if (x1==6) x1=v1[order[q]].indexOf('href=')+5;
    	    x2=v1[order[q]].indexOf('>');
    	    if (x1>0 && x2>0)
    	    {
    	      tmp=v1[order[q]].substring(x1,x2);
          	x2=tmp.indexOf(' ');
    	      if (x2>0) tmp=tmp.substring(0,x2);
    	      if (tmp.substring(0,1)=="'") tmp=tmp.substring(1,tmp.length-1);
    	      if (tmp.substring(0,1)=='"') tmp=tmp.substring(1,tmp.length-1);
          	document.write("<table border=0 width=500><tr><td><span class='xresult'>"+v3[order[q]]+"</span></td></tr></table><span class='xlocation'></span><br><br>");
    //document.write("<table border=0 width=500><tr><td><span class='xresult'>"+v3[order[q]]+"</span><br><br>");
    	    }
    	    q2++;
       	}
    	  q+=1;
    	}
     
    	if (finds>20)
    	{
    	  document.write("<BR>");
    	  pages=Math.round(finds/20);
    	  if (finds%20<6)	pages++;
     
    	// Create the parameter string
      	paramstring=searchname+"?keywords="+keyword+"&and="+andresult+"&sort="+SortResults;
    	  document.write("<center><span class='xsmall'>");
    ////// modifications possibles ///////
    	  if (display_start>1) document.write("<a href='"+paramstring+"&disp="+(display_start-20)+"'>page pr&eacute;c&eacute;dente</a>");
    	  document.write("&nbsp;&nbsp;&nbsp;");
    	  for (i=1; i<=pages;)
        {
    	    if ((((i-1)*20)+1)<=sites)
          {
    	      document.write("<a href='"+paramstring+"&disp="+(((i-1)*20)+1)+"'>"+i+"</a>&nbsp&nbsp ");
    	    }
    	    i++;
    	  }
    	  document.write("&nbsp;&nbsp;&nbsp;");
    	  if (displast<=sites) document.write("<a href='"+paramstring+"&disp="+(displast)+"'>page suivante</a>");
    	  document.write("</span></center>");
    	}
    ////// fin de  modifications ///////			
    	DisplaySearch();
    	document.close();
    }
     
    function Cat()
    {
    	document.open();
    	document.clear();
    	AddBody();
    	DisplaySearch();
    	document.close();
    }
     
     
    function makeArray(n,vartype) 
    {
    	this.length = n;
    	for (var k = 1; k <= n; k++) 
      {
    	  if (vartype==0)
        {
    	    this[k] = "";
    	  }
        else
        {
    	    this[k] = 0;
    	  }
    	}
    	return this;
    }               
     
    function stripInput(key)
    {
    	while(key.substring(0,1) == ","  || key.substring(0,1) == " " ) key = key.substring(1,key.length);
    	while(key.substring(key.length-1,key.length) == "," || key.substring(key.length-1,key.length) == " ") key = 			key.substring(0,key.length-1);
    	return key;
    }
     
    function parseIt(key) 
    {
    	key = stripInput(key)+" ";
    	var y = 1;
    	while(key.indexOf(" ") > 0)
    	{
      	if (key.substring(0,1)=='"')
    	  {
    	    var pos=key.indexOf('"',2);
    	    keywords[y]=key.substring(1,pos);
    	    keywords[y]=stripInput(keywords[y]);
    	    y++;
    	    key=key.substring(pos+1,key.length);
    	  }
        else
        {
    	    var pos=key.indexOf(' AND ');
    	    if ((pos>0) && (key.indexOf(' ')>=pos))
    	    {
    	      pos=key.indexOf(' ',pos+5);
    	      keywords[y]=key.substring(0,pos);
    	      keywords[y]=stripInput(keywords[y]);
    	      y++;
    	      key=key.substring(pos+1,key.length);
    	      if (key.substring(0,4)=='AND ')
    	      {
    	        pos=keywords[y-1].indexOf(' ')+5;
    	        key=keywords[y-1].substring(pos,keywords[y-1].length)+' '+key;
    	      }
    	    }
          else
          {
    	      var pos=key.indexOf(' OR ');
    	      if ((pos>0) && (key.indexOf(' ')>=pos))
    	      {
    	        pos=key.indexOf(' ');
    	        keywords[y]=key.substring(0,pos);
    	        keywords[y]=stripInput(keywords[y]);
    	        if (keywords[y]!=keywords[y-1])	y++;
    	        key=key.substring(pos+1,key.length);
    	        pos=key.indexOf('OR ');
    	        key=key.substring(pos+3,key.length);
    	        pos=key.indexOf(' ');
    	        keywords[y]=key.substring(0,pos);
    	        keywords[y]=stripInput(keywords[y]);
    	        y++;
    	        key=key.substring(pos+1,key.length);
    	        if (key.substring(0,3)=='OR ') key=keywords[y-1]+' '+key;
    	      }
            else
            {
    	        var pos = key.indexOf(" ");
    	        keywords[y]=key.substring(0,pos);
    	        keywords[y] = stripInput(keywords[y]); 
    	        y++;
    	        if(y > 50) return -1
    	          key=key.substring(pos+1,key.length);
    	      }
    	    }
    	  }
    	}
    	return y-1;
    }
     
    var keywords = new makeArray(50,0);
    var results;
    var foundword;
    var data;
    var order;
    var total_keywords;
     
    function dataEntry ()
    {
    	this.v1="";
    	this.v2="";
    	return this;
    }
     
    function makeRecordLinks(size)
    {
    	this.length = size;
    	for (var r=1; r<= size; r++) 
    	{
        this[r] = new dataEntry();
    	  this[r].v1 = v1[r];
    	  this[r].v2 = v2[r]; 
    	}
    	return this;
    }
     
     
    // Page HTML telle que vue à l'écran
    function AddBody()
    {
    	var keytext='"'+searchname+'?keywords="+';
    	var andtext='"&and="+';
    	document.write('<script>function doSearch(){'+
    	'searchwords=document.searchform.searchwords.value; '+
    	'while (searchwords.indexOf(" ")>-1){ pos=searchwords.indexOf(" ");'+
    	'searchwords=searchwords.substring(0,pos)+"+"+searchwords.substring(pos+1); }'+
    	'document.location='+keytext+' searchwords+'+andtext+'"0"}'+
    	'<'+'/'+'script>'
    	);
     
    	templateBody();
    ////// modifications possibles ///////
     
    	document.write('<p><br></p><table width=0><tr><td width=0><font color="#000000"><font face="Arial" size="10"><font face=Arial, Verdana size=2>Taper le ou les mots correspondant(s) à la recherche.</font></font></td><td width=0></td></tr></table><table border=0 width=0><tr><td>');
    	document.write("<br><form name='searchform' method='post' action='javascript:doSearch()'><table border='0' width='100%'><tr><td 	align='center'><font face='Arial' size='6'><input name='searchwords' type='text' size='65'>&nbsp;&nbsp;<a 	href='javascript:doSearch()'>"+ButtonCode+"</a></font></td></tr></table></form>");
    	document.write('<p><br></p><table width=0><tr><td width=0><font color="#000000"><font face="Arial" size="10"><font face=Arial, Verdana size=2>Lorsque plusieurs mots clés sont saisis, la recherche s\'effectue dans les pages où au moins l\'un des mots apparaît.</font></font></td><td width=0></td></tr></table><table border=0 width=0><tr><td>');
    	document.write('<font face="Arial" size="10"><font face=Arial, Verdana size=2>Sacisir AND entre chaque mots clés (exemple : mot1 AND mot2), afin de rechercher les pages dans lesquelles tous les mots clés saisis apparaissent.</font></font></td><td width=0></td></tr></table><table border=0 width=0><tr><td>');
     //document.write(navigator.appName);
      if (navigator.appName!="Netscape")
        document.searchform.searchwords.focus();
    ////// fin de  modifications ///////			
    	if (usebannercode) bannerCode();
    }
     
     
    // Inscription Bas de page + fin de code HTML pour la page
    function DisplaySearch()
    {
    ////// modifications possibles ///////
    //document.write("<center><hr size=1></center>")
    //	document.write("<Font size=-1><center>R&eacute;alis&eacute; avec <a href=http://www.twicefun.com/just4fun>Search 	"+version+"</a>  - Free Javascript SearchEngine</center></font>");
    ////// fin de  modifications ///////		
    	templateEnd();
    }
     
    function search(records, keyword)
    {
    	var hit=0;
    	var addcomplete=0;
     
    	for (q=1; q<=records.length; q++) 
      {
    	  addcomplete=0;
    	  search_parm=records[q].v2.toLowerCase()+" "+v3[q].toLowerCase();
     
    	  if (keyword.indexOf(' AND ')>0)
    	  {
    	    firstword=keyword.substring(0,keyword.indexOf(' '));
    	    lastword=keyword.substring(keyword.indexOf(' AND ')+5,keyword.length);
    	    if ((search_parm.indexOf(" "+firstword+" ") != -1) && (search_parm.indexOf(" "+lastword+" ")!= -1 ))
    	    {
    	      hit++;
    	      finds++;
    	      if(hit < 2)
    	      { 
    	        if (results[q]==0) sites++;
    	          results[q] +=2;
    	      } 
    	    }
    	  }
        else
        {
    	    keyword=keyword.toLowerCase();
    	    if ((search_parm.indexOf(" "+keyword+" ") != -1) ||(keyword=="[all]"))
    	    {
    	      hit++;
    	      finds++;
    	      if(hit<2)
    	      { 
    	        if (results[q]==0) sites++;
    	        results[q]+=2;
    	      } 
    	    }
          else
          {
    	// check for a half hit (ie. search:share find:SHAREware)
          	if (search_parm.indexOf(keyword) != -1)
    	      {
    	        hit++;
    	        finds++;
    	        if(hit < 2)
    	        {
    	          if (results[q]==0) sites++;
    	          results[q]+=1;
    	          x=search_parm.indexOf(keyword)+keyword.length;
    	          pos=search_parm.substring(1,x-keyword.length);
    	          while (pos.indexOf(" ")!=-1)
    	          {
    	            y=pos.indexOf(" ");
    	            pos=pos.substring(y+1,pos.length);
    	          }
    	          if (pos.length<=2) addcomplete++;
     
    	          pos=search_parm.substring(x,search_parm.length);
    	          fullresult=search_parm.substring(x,x+pos.indexOf(" "));
     
    	          if (fullresult.length<=2) addcomplete++;
    	          if (addcomplete>1) results[q]+=1;
    	        }
    	      }
    	     }
    	    }
    	    hit=0;
      } 
    }                                       
     
    var searchwords = '';
    var newload = true;
     
    function countParams(text)
    {
    	pos=-1;
    	tmp = "";
    	if (text=='') return 0;
    	text=text+'&';
    	i=0;
    	while (text.length>0)
    	{
      	pos=text.indexOf('&',0);
    	  tmp=text.substring(pos+1);
      	text=tmp;
    	  i++;
    	}
    	return i;
    }	
     
    function getCommand(text,val)
    {
    	pos=-2;
    	tmp = "";
    	text=text+'&';
    	for (i=0; i<=val;)
    	{
      	pos2=pos+2;
    	  pos=text.indexOf('&',pos2);
      	tmp=text.substring(pos,pos2-1);
    	  i++;
    	}
    	text=tmp;
    	pos=text.indexOf('=',0);
    	if (pos!=-1) tmp=text.substring(pos,0);
    	tmp=tmp.toLowerCase();
    	return tmp;
    }
     
    function getValues(text,val)
    {
    	pos=-2;
    	tmp = "";
    	text=text+'&';
    	for (i=0; i<=val;)
    	{
      	pos2=pos+2;
    	  pos=text.indexOf('&',pos2);
      	tmp=text.substring(pos,pos2-1);
    	  i++;
    	}
    	text=tmp;
    	pos2=text.indexOf('=',0)+1;
    	if (pos2!=-1)
    	{
    	  tmp=text.substring(pos2);
    	} 
      else 
      { 
    	  tmp='' 
    	}
     
    	pos=-2;
    	text=tmp;	
    	if (text.indexOf('%20')>0)
    	{
    	  pos=text.indexOf('%20',0);
      	tmp=text.substring(0,pos2-4)+' '+text.substring(pos2-1,text.length);
    	  text=tmp;
    	}
    	return tmp;
    }		
     
    function initSearch()
    {
    	if (searchwords!='')
    	{
      	searchAll(searchwords);
    	}
      else 
      {
      	if (newload) Cat();
    	}
    }
     
    function doParamStuff(findw)
    {
    	Myparams=countParams(findw);
    	if (Myparams>0)
    	{
      	for (cnt=0; cnt<Myparams;)
    	  {
        	tempw=getCommand(findw,cnt);
        	tempv=getValues(findw,cnt);
        	if (tempw=='keywords')
        	{
          	searchwords=getValues(findw,cnt);
          	origsearchwords=searchwords;
          	while (searchwords.indexOf('+')>-1)
          	{
            	pos=searchwords.indexOf('+');
            	searchwords=searchwords.substring(0,pos)+' '+searchwords.substring(pos+1);
          	}
    	    }
        	if (tempw=='sort')
        	{
          	if ((tempv=='0')||(tempv=='false'))
          	{
            	SortResults=false;
          	}
            else
            {
            	SortResults=true;
    	      }
    	    }
     
      	  if (tempw=='and')
        	{
          	if ((tempv=='1')||(tempv=='true'))
          	{
            	andresult=true;
    	      }
            else
            {
            	andresult=false;
    	      }
    	    }
        	if (tempw=='disp') display_start=parseInt(tempv);
    	    cnt +=1;
    	  }
    	}
    }
     
    findw=document.location.search;
    findw="&"+findw.substring(1,findw.length);
     
    while (findw.indexOf('%20')>0)
    {
    	pos2=findw.indexOf('%20',0);
    	tmp=findw.substring(0,pos2)+' '+findw.substring(pos2+3,findw.length);
    	findw=tmp;
    }
    doParamStuff(findw);
    Page principale Principal.htm:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <html>
    <head>
    <script language="Javascript" src="db.js"></script>
    <script language="Javascript" src="search.js"></script>
    </head>
    <body>
    <!-- saved from url=(0013)about:internet -->
    <script language="Javascript">
    initSearch();
    </script>	
    </body>
    </html>
    Page de sommaire (à gauche) : Sommaire.htm
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <html>
    <head>
    <title>Sommaire</title>
    <base target="main">
    </head>
    <body>
    <span id="1">Sommaire</span>
    </body>
    </html>
    Page de frame : Index.htm
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
      <frameset name="tocbody" framespacing="5" cols="248,*">
        <noframes>
        <p>This page uses frames, but your browser doesn't support them.</p>
        </noframes>
        <frame name="contents" target="main" src="sommaire.htm" scrolling="auto" resize="no">
        <frame name="main" src="principal.htm" scrolling="auto" target="_self">
      </frameset>
    </frameset>
    Merci d'avance !
    A+

  17. #17
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 59
    Par défaut
    Personne n'a d'idée ?
    J'ai essayé de charger la page avant et après la fontion de recherche mais rien n'y fait !
    Il n'y a pas un pro du JS qui traine par là et qui pourrait me guider ?

Discussions similaires

  1. Appel d'un lien depuis une page de site
    Par eugiragal dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 01/04/2007, 09h46
  2. [MySQL] Lien depuis une table
    Par urbalk dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 28/01/2007, 09h56
  3. [Tableaux] Lien depuis une image
    Par hedi_wazo2001 dans le forum Langage
    Réponses: 5
    Dernier message: 21/12/2006, 11h12
  4. Liens depuis une base de donnée statique
    Par LucG dans le forum Access
    Réponses: 4
    Dernier message: 26/10/2005, 11h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo